2#if defined(HAVE_CONFIG_H)
7#pragma clang diagnostic ignored "-Wdeprecated"
12#include <CoreFoundation/CoreFoundation.h>
13#include <CoreServices/CoreServices.h>
14#include <Security/Security.h>
16#include <openssl/e_os2.h>
17#include <openssl/evp.h>
18#include <openssl/crypto.h>
19#include <openssl/err.h>
20#include <openssl/pem.h>
21#include <openssl/pkcs7.h>
22#include <openssl/ossl_typ.h>
23#include <openssl/x509.h>
24#include <openssl/x509v3.h>
25#include <openssl/ssl.h>
33#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
49 OSStatus status = noErr;
51 const char *pathName = nil;
52 SInt32 MacVersion = 0;
54 if (Gestalt(gestaltSystemVersion, &MacVersion) == noErr)
56 if (MacVersion >= 0x1050)
59 pathName =
"/System/Library/Keychains/SystemRootCertificates.keychain";
64 pathName =
"/System/Library/Keychains/X509Anchors";
69 ErrLog( <<
"Cannot retrieve OS version");
75 SecKeychainRef systemCertsKeyChain;
76 status = ::SecKeychainOpen(
83 ErrLog( <<
"X509Anchors keychain could not be opened");
91 SecKeychainSearchRef searchReference = nil;
92 status = ::SecKeychainSearchCreateFromAttributes(
94 kSecCertificateItemClass,
102 ::CFRelease(systemCertsKeyChain);
106 ErrLog( <<
"System certificate store cannot be opened");
111 InfoLog( <<
"System certificate store opened");
112 return searchReference;
118 if (NULL == searchReference)
121 ::CFRelease(searchReference);
127 SecKeychainSearchRef searchReference = NULL;
131 if (searchReference == NULL)
137 OSStatus status = noErr;
138 SecKeychainItemRef itemRef = nil;
141 status = ::SecKeychainSearchCopyNext(
145 if (status == errSecItemNotFound)
156 status = ::SecKeychainItemCopyAttributesAndData(
165 if (status == noErr && data != NULL)
170 status = ::SecKeychainItemFreeAttributesAndData(NULL, data);
176 ::CFRelease(itemRef);
181 ErrLog( <<
"Couldn't load certificate, error code: " << status);
198 pErrCert = X509_STORE_CTX_get_current_cert(pInStore);
199 iErr = X509_STORE_CTX_get_error(pInStore);
200 iDepth = X509_STORE_CTX_get_error_depth(pInStore);
202 if (NULL != pErrCert)
203 X509_NAME_oneline(X509_get_subject_name(pErrCert),cBuf1,256);
205 snprintf(cBuf2,
sizeof(cBuf2),
"depth=%d %s\n",iDepth,cBuf1);
208 memset(cBuf2, 0,
sizeof(cBuf2) );
209 snprintf(cBuf2,
sizeof(cBuf2),
"\n Error %s", X509_verify_cert_error_string(X509_STORE_CTX_get_error(pInStore)) );
int verifyCallback(int iInCode, X509_STORE_CTX *pInStore)
#define resip_assert(x)
This file needs to work for both C and C++ code.
void addCertDER(PEMType type, const Data &name, const Data &certDER, bool write)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
@ Borrow
The Data instance is borrowing the memory from the passed in buffer.
KeychainHandle openSystemCertStore()
void closeCertifStore(KeychainHandle searchReference)
dcm! – add UnusedChecking(_enum) below;