Skip to content

Commit 875f45f

Browse files
[release/6.0-staging] Fix copying ephemeral keys to keychains.
Starting on macOS Sequoia, at least in beta, SecKeychainitemCopyKeychain no longer returns errSecNoSuchKeychain for ephemeral keys. Instead, it returns errSecInvalidItemRef. This adds the error code in the handling logic for when we need to add an ephemeral key to the target keychain. Co-authored-by: Kevin Jones <[email protected]>
1 parent 26c2e13 commit 875f45f

File tree

1 file changed

+1
-1
lines changed
  • src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple

1 file changed

+1
-1
lines changed

src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509_macos.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ int32_t AppleCryptoNative_X509CopyWithPrivateKey(SecCertificateRef cert,
391391
SecKeychainItemRef itemCopy = NULL;
392392

393393
// This only happens with an ephemeral key, so the keychain we're adding it to is temporary.
394-
if (status == errSecNoSuchKeychain)
394+
if (status == errSecNoSuchKeychain || status == errSecInvalidItemRef)
395395
{
396396
status = AddKeyToKeychain(privateKey, targetKeychain, NULL);
397397
}

0 commit comments

Comments
 (0)