Skip to content

Suppress warnings for deprecated keychain APIs #77911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ int32_t AppleCryptoNative_SecKeychainItemCopyKeychain(SecKeychainItemRef item, S

if (itemType == SecKeyGetTypeID() || itemType == SecIdentityGetTypeID() || itemType == SecCertificateGetTypeID())
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSStatus status = SecKeychainItemCopyKeychain(item, pKeychainOut);
#pragma clang diagnostic pop

if (status == noErr)
{
Expand All @@ -40,20 +43,29 @@ int32_t AppleCryptoNative_SecKeychainCreate(const char* pathName,
const uint8_t* passphraseUtf8,
SecKeychainRef* pKeychainOut)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainCreate(pathName, passphraseLength, passphraseUtf8, false, NULL, pKeychainOut);
#pragma clang diagnostic pop
}

int32_t AppleCryptoNative_SecKeychainDelete(SecKeychainRef keychain)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainDelete(keychain);
#pragma clang diagnostic pop
}

int32_t AppleCryptoNative_SecKeychainCopyDefault(SecKeychainRef* pKeychainOut)
{
if (pKeychainOut != NULL)
*pKeychainOut = NULL;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainCopyDefault(pKeychainOut);
#pragma clang diagnostic pop
}

int32_t AppleCryptoNative_SecKeychainOpen(const char* pszKeychainPath, SecKeychainRef* pKeychainOut)
Expand All @@ -64,12 +76,18 @@ int32_t AppleCryptoNative_SecKeychainOpen(const char* pszKeychainPath, SecKeycha
if (pszKeychainPath == NULL)
return errSecParam;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainOpen(pszKeychainPath, pKeychainOut);
#pragma clang diagnostic pop
}

int32_t AppleCryptoNative_SecKeychainUnlock(SecKeychainRef keychain, uint32_t passphraseLength, const uint8_t* passphraseUtf8)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainUnlock(keychain, passphraseLength, passphraseUtf8, true);
#pragma clang diagnostic pop
}

int32_t AppleCryptoNative_SetKeychainNeverLock(SecKeychainRef keychain)
Expand All @@ -81,7 +99,10 @@ int32_t AppleCryptoNative_SetKeychainNeverLock(SecKeychainRef keychain)
.lockInterval = INT_MAX,
};

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return SecKeychainSetSettings(keychain, &settings);
#pragma clang diagnostic pop
}

static int32_t
Expand Down Expand Up @@ -262,7 +283,7 @@ static bool IsCertInKeychain(CFTypeRef needle, SecKeychainRef haystack)
{
ret = false;
}

if (result != NULL)
{
CFRelease(result);
Expand Down Expand Up @@ -355,7 +376,10 @@ int32_t AppleCryptoNative_X509StoreAddCertificate(CFTypeRef certOrIdentity, SecK
// keychain back to disk.
if (status == noErr && privateKey != NULL)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
status = SecKeychainItemCreateCopy((SecKeychainItemRef)privateKey, keychain, NULL, &itemCopy);
#pragma clang diagnostic pop
}

if (status == errSecDuplicateItem)
Expand All @@ -374,7 +398,10 @@ int32_t AppleCryptoNative_X509StoreAddCertificate(CFTypeRef certOrIdentity, SecK

if (status == noErr && cert != NULL)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
status = SecKeychainItemCreateCopy((SecKeychainItemRef)cert, keychain, NULL, &itemCopy);
#pragma clang diagnostic pop
}

if (status == errSecDuplicateItem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@ int32_t AppleCryptoNative_X509CopyWithPrivateKey(SecCertificateRef cert,
}

SecKeychainRef keyKeychain = NULL;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSStatus status = SecKeychainItemCopyKeychain((SecKeychainItemRef)privateKey, &keyKeychain);
#pragma clang diagnostic pop
SecKeychainItemRef itemCopy = NULL;

// This only happens with an ephemeral key, so the keychain we're adding it to is temporary.
Expand Down Expand Up @@ -536,7 +538,10 @@ int32_t AppleCryptoNative_X509MoveToKeychain(SecCertificateRef cert,

SecKeychainRef curKeychain = NULL;
SecKeyRef importedKey = NULL;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OSStatus status = SecKeychainItemCopyKeychain((SecKeychainItemRef)cert, &curKeychain);
#pragma clang diagnostic pop

if (status == errSecNoSuchKeychain)
{
Expand All @@ -559,7 +564,10 @@ int32_t AppleCryptoNative_X509MoveToKeychain(SecCertificateRef cert,

if (status == noErr && privateKey != NULL)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
status = SecKeychainItemCopyKeychain((SecKeychainItemRef)privateKey, &curKeychain);
#pragma clang diagnostic pop

if (status == errSecNoSuchKeychain)
{
Expand Down