internal static void X509StoreRemoveCertificate(SafeKeychainItemHandle certHandle, SafeKeychainHandle keychain, bool isReadOnlyMode) { int osStatus; int ret = AppleCryptoNative_X509StoreRemoveCertificate(certHandle, keychain, isReadOnlyMode, out osStatus); if (ret == 0) { throw CreateExceptionForOSStatus(osStatus); } const int SuccessOrNoMatch = 1; const int UserTrustExists = 2; const int AdminTrustExists = 3; const int ReadOnlyDelete = 4; switch (ret) { case SuccessOrNoMatch: break; case UserTrustExists: throw new CryptographicException(SR.Cryptography_X509Store_WouldModifyUserTrust); case AdminTrustExists: throw new CryptographicException(SR.Cryptography_X509Store_WouldModifyAdminTrust); case ReadOnlyDelete: throw new CryptographicException(SR.Cryptography_X509_StoreReadOnly); default: Debug.Fail($"Unexpected result from AppleCryptoNative_X509StoreRemoveCertificate: {ret}"); throw new CryptographicException(); } }
internal static void X509StoreAddCertificate(SafeKeychainItemHandle certOrIdentity, SafeKeychainHandle keychain) { int osStatus; int ret = AppleCryptoNative_X509StoreAddCertificate(certOrIdentity, keychain, out osStatus); if (ret == 0) { throw CreateExceptionForOSStatus(osStatus); } if (ret != 1) { Debug.Fail($"Unexpected result from AppleCryptoNative_X509StoreAddCertificate: {ret}"); throw new CryptographicException(); } }
internal static SafeKeychainHandle SecKeychainItemCopyKeychain(SafeKeychainItemHandle item) { bool addedRef = false; try { item.DangerousAddRef(ref addedRef); var handle = SecKeychainItemCopyKeychain(item.DangerousGetHandle()); return(handle); } finally { if (addedRef) { item.DangerousRelease(); } } }
private static partial int AppleCryptoNative_X509StoreRemoveCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, bool isReadOnlyMode, out int pOSStatus);
private static partial int AppleCryptoNative_X509StoreAddCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, out int pOSStatus);
internal static SafeKeychainHandle SecKeychainItemCopyKeychain(SafeKeychainItemHandle item) => SecKeychainItemCopyKeychain((SafeHandle)item);
private static extern int AppleCryptoNative_X509StoreRemoveCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, out int pOSStatus);
private static partial int AppleCryptoNative_X509StoreRemoveCertificate( SafeKeychainItemHandle cert, SafeKeychainHandle keychain, [MarshalAs(UnmanagedType.Bool)] bool isReadOnlyMode, out int pOSStatus);