crypt32: Read trusted root certificates from system keychain on Mac OS X.

oldstable
Ken Thomases 2009-11-20 15:49:11 -06:00 committed by Alexandre Julliard
parent ff57ba9d7c
commit 3921454398
2 changed files with 33 additions and 0 deletions

View File

@ -6,6 +6,7 @@ VPATH = @srcdir@
MODULE = crypt32.dll
IMPORTLIB = crypt32
IMPORTS = user32 advapi32 kernel32 ntdll
EXTRALIBS = @SECURITYLIB@
C_SRCS = \
base64.c \

View File

@ -40,6 +40,9 @@
#include "winternl.h"
#include "wine/debug.h"
#include "crypt32_private.h"
#ifdef __APPLE__
#include <Security/Security.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
@ -713,6 +716,35 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
DWORD i;
BOOL ret = FALSE;
#ifdef __APPLE__
OSStatus status;
CFArrayRef rootCerts;
status = SecTrustCopyAnchorCertificates(&rootCerts);
if (status == noErr)
{
int i;
for (i = 0; i < CFArrayGetCount(rootCerts); i++)
{
SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(rootCerts, i);
CFDataRef certData;
if ((status = SecKeychainItemExport(cert, kSecFormatX509Cert, 0, NULL, &certData)) == noErr)
{
if (CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
CFDataGetBytePtr(certData), CFDataGetLength(certData),
CERT_STORE_ADD_NEW, NULL))
ret = TRUE;
else
WARN("adding root cert %d failed: %08x\n", i, GetLastError());
CFRelease(certData);
}
else
WARN("could not export certificate %d to X509 format: 0x%08x\n", i, (unsigned int)status);
}
CFRelease(rootCerts);
}
#endif
for (i = 0; !ret &&
i < sizeof(CRYPT_knownLocations) / sizeof(CRYPT_knownLocations[0]);
i++)