         var trustedAppSelf: SecTrustedApplication?
         var trustedAppSystemUIServer: SecTrustedApplication?
 
+        let kSecReturnWorkingReference: CFString
+        let kSecValueWorkingReference: CFString
+        if #available(macOS 10.15, *) {
+            // macOS Catalina requires a persistent ref to pass this test.
+            kSecReturnWorkingReference = kSecReturnPersistentRef
+            kSecValueWorkingReference = kSecValuePersistentRef
+        } else {
+            kSecReturnWorkingReference = kSecReturnRef
+            kSecValueWorkingReference = kSecValueRef
+        }
+
         XCTAssertEqual(SecTrustedApplicationCreateFromPath(nil, &trustedAppSelf), errSecSuccess)
         XCTAssertEqual(SecTrustedApplicationCreateFromPath("/System/Library/CoreServices/SystemUIServer.app", &trustedAppSystemUIServer), errSecSuccess);
         let trustedList = [trustedAppSelf!, trustedAppSystemUIServer!] as NSArray?

        XCTAssertTrue(valet.containsObject(forKey: vulnKey))

        // Obtain a reference to the vulnerable keychain entry.
        query[kSecReturnPersistentRef as String] = true
        query[kSecReturnAttributes as String] = true
        var vulnerableEntryReference: CFTypeRef?
        XCTAssertEqual(SecItemCopyMatching(query as CFDictionary, &vulnerableEntryReference), errSecSuccess)

            XCTFail()
            return
        }
        guard let vulnerableValueRef = vulnerableKeychainEntry[kSecValueWorkingReference as String] else {
            XCTFail()
            return
        }

        let queryWithVulnerableReference = [
            kSecValueWorkingReference as String: vulnerableValueRef
            ] as CFDictionary
        // Demonstrate that the item is accessible with the reference.
        XCTAssertEqual(SecItemCopyMatching(queryWithVulnerableReference, nil), errSecSuccess)
