@@ -16,59 +16,6 @@ package x509
16
16
#include <CoreFoundation/CoreFoundation.h>
17
17
#include <Security/Security.h>
18
18
19
- // FetchPEMRoots_MountainLion is the version of FetchPEMRoots from Go 1.6
20
- // which still works on OS X 10.8 (Mountain Lion).
21
- // It lacks support for admin & user cert domains.
22
- // See golang.org/issue/16473
23
- int FetchPEMRoots_MountainLion(CFDataRef *pemRoots) {
24
- if (pemRoots == NULL) {
25
- return -1;
26
- }
27
- CFArrayRef certs = NULL;
28
- OSStatus err = SecTrustCopyAnchorCertificates(&certs);
29
- if (err != noErr) {
30
- return -1;
31
- }
32
- CFMutableDataRef combinedData = CFDataCreateMutable(kCFAllocatorDefault, 0);
33
- int i, ncerts = CFArrayGetCount(certs);
34
- for (i = 0; i < ncerts; i++) {
35
- CFDataRef data = NULL;
36
- SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs, i);
37
- if (cert == NULL) {
38
- continue;
39
- }
40
- // Note: SecKeychainItemExport is deprecated as of 10.7 in favor of SecItemExport.
41
- // Once we support weak imports via cgo we should prefer that, and fall back to this
42
- // for older systems.
43
- err = SecKeychainItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data);
44
- if (err != noErr) {
45
- continue;
46
- }
47
- if (data != NULL) {
48
- CFDataAppendBytes(combinedData, CFDataGetBytePtr(data), CFDataGetLength(data));
49
- CFRelease(data);
50
- }
51
- }
52
- CFRelease(certs);
53
- *pemRoots = combinedData;
54
- return 0;
55
- }
56
-
57
- // useOldCode reports whether the running machine is OS X 10.8 Mountain Lion
58
- // or older. We only support Mountain Lion and higher, but we'll at least try our
59
- // best on older machines and continue to use the old code path.
60
- //
61
- // See golang.org/issue/16473
62
- int useOldCode() {
63
- char str[256];
64
- size_t size = sizeof(str);
65
- memset(str, 0, size);
66
- sysctlbyname("kern.osrelease", str, &size, NULL, 0);
67
- // OS X 10.8 is osrelease "12.*", 10.7 is 11.*, 10.6 is 10.*.
68
- // We never supported things before that.
69
- return memcmp(str, "12.", 3) == 0 || memcmp(str, "11.", 3) == 0 || memcmp(str, "10.", 3) == 0;
70
- }
71
-
72
19
// FetchPEMRoots fetches the system's list of trusted X.509 root certificates.
73
20
//
74
21
// On success it returns 0 and fills pemRoots with a CFDataRef that contains the extracted root
@@ -80,10 +27,6 @@ int useOldCode() {
80
27
int FetchPEMRoots(CFDataRef *pemRoots, CFDataRef *untrustedPemRoots) {
81
28
int i;
82
29
83
- if (useOldCode()) {
84
- return FetchPEMRoots_MountainLion(pemRoots);
85
- }
86
-
87
30
// Get certificates from all domains, not just System, this lets
88
31
// the user add CAs to their "login" keychain, and Admins to add
89
32
// to the "System" keychain
0 commit comments