OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/certificate_viewer.h" | 5 #include "chrome/browser/certificate_viewer.h" |
6 | 6 |
7 #include <Security/Security.h> | 7 #include <Security/Security.h> |
8 #include <SecurityInterface/SFCertificatePanel.h> | 8 #include <SecurityInterface/SFCertificatePanel.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 CFArrayAppendValue(certificates, cert_mac); | 28 CFArrayAppendValue(certificates, cert_mac); |
29 | 29 |
30 // Server certificate must be first in the array; subsequent certificates | 30 // Server certificate must be first in the array; subsequent certificates |
31 // in the chain can be in any order. | 31 // in the chain can be in any order. |
32 const std::vector<SecCertificateRef>& ca_certs = | 32 const std::vector<SecCertificateRef>& ca_certs = |
33 cert->GetIntermediateCertificates(); | 33 cert->GetIntermediateCertificates(); |
34 for (size_t i = 0; i < ca_certs.size(); ++i) | 34 for (size_t i = 0; i < ca_certs.size(); ++i) |
35 CFArrayAppendValue(certificates, ca_certs[i]); | 35 CFArrayAppendValue(certificates, ca_certs[i]); |
36 | 36 |
37 [[[SFCertificatePanel alloc] init] | 37 // Explicitly disable revocation checking, regardless of user preferences |
38 beginSheetForWindow:parent | 38 // or system settings. The behaviour of SFCertificatePanel is to call |
39 modalDelegate:nil | 39 // SecTrustEvaluate on the certificate(s) supplied, effectively |
40 didEndSelector:NULL | 40 // duplicating the behaviour of net::X509Certificate::Verify(). However, |
41 contextInfo:NULL | 41 // this call stalls the UI if revocation checking is enabled in the |
42 certificates:reinterpret_cast<NSArray*>(certificates.get()) | 42 // Keychain preferences or if the cert may be an EV cert. By disabling |
43 showGroup:YES]; | 43 // revocation checking, the stall is limited to the time taken for path |
| 44 // building and verification, which should be minimized due to the path |
| 45 // being provided in |certificates|. This does not affect normal |
| 46 // revocation checking from happening, which is controlled by |
| 47 // net::X509Certificate::Verify() and user preferences, but will prevent |
| 48 // the certificate viewer UI from displaying which certificate is revoked. |
| 49 // This is acceptable, as certificate revocation will still be shown in |
| 50 // the page info bubble if a certificate in the chain is actually revoked. |
| 51 base::mac::ScopedCFTypeRef<CFMutableArrayRef> policies( |
| 52 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); |
| 53 if (!policies.get()) { |
| 54 NOTREACHED(); |
| 55 return; |
| 56 } |
| 57 // Add a basic X.509 policy, in order to match the behaviour of |
| 58 // SFCertificatePanel when no policies are specified. |
| 59 SecPolicyRef basic_policy = NULL; |
| 60 OSStatus status = net::X509Certificate::CreateBasicX509Policy(&basic_policy); |
| 61 if (status != noErr) { |
| 62 NOTREACHED(); |
| 63 return; |
| 64 } |
| 65 CFArrayAppendValue(policies, basic_policy); |
| 66 CFRelease(basic_policy); |
| 67 |
| 68 status = net::X509Certificate::CreateRevocationPolicies(false, policies); |
| 69 if (status != noErr) { |
| 70 NOTREACHED(); |
| 71 return; |
| 72 } |
| 73 |
| 74 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; |
| 75 [panel setPolicies:(id)policies.get()]; |
| 76 [panel beginSheetForWindow:parent |
| 77 modalDelegate:nil |
| 78 didEndSelector:NULL |
| 79 contextInfo:NULL |
| 80 certificates:reinterpret_cast<NSArray*>(certificates.get()) |
| 81 showGroup:YES]; |
44 // The SFCertificatePanel releases itself when the sheet is dismissed. | 82 // The SFCertificatePanel releases itself when the sheet is dismissed. |
45 } | 83 } |
OLD | NEW |