From 936691983f74b1fe1d83859a784b2a5f51d28bba Mon Sep 17 00:00:00 2001 From: Maryam Ariyan Date: Thu, 5 Jul 2018 11:45:41 -0400 Subject: [PATCH] Returns error code rather than asserting --- .../System.Security.Cryptography.Native.Apple/pal_x509.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509.c b/src/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509.c index 4bb670c97461..d15ed63d1c7e 100644 --- a/src/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509.c +++ b/src/Native/Unix/System.Security.Cryptography.Native.Apple/pal_x509.c @@ -61,7 +61,7 @@ AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKey *pOSStatusOut = noErr; if (cert == NULL || pPublicKeyOut == NULL || pOSStatusOut == NULL) - return kErrorBadInput; + return kErrorUnknownState; pthread_once (&once, InitCertificateCopy); // SecCertificateCopyPublicKey was deprecated in 10.14, so use SecCertificateCopyKey on the systems that have it (10.14+), @@ -70,11 +70,14 @@ AppleCryptoNative_X509GetPublicKey(SecCertificateRef cert, SecKeyRef* pPublicKey { *pPublicKeyOut = (*secCertificateCopyKey)(cert); } - else + else if (secCertificateCopyPublicKey != NULL) { - assert(secCertificateCopyPublicKey != NULL); *pOSStatusOut = (*secCertificateCopyPublicKey)(cert, pPublicKeyOut); } + else + { + return kErrorBadInput; + } return (*pOSStatusOut == noErr); }