Chromium Code Reviews| 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 or |
| 38 beginSheetForWindow:parent | 38 // system settings. The behaviour of SFCertificatePanel is to call |
| 39 modalDelegate:nil | 39 // SecTrustEvaluate on the certificate(s) supplied, effectively duplicating |
| 40 didEndSelector:NULL | 40 // the behaviour of net::X509Certificate::Verify(). However, the call is |
| 41 contextInfo:NULL | 41 // made in such a way as to stall the UI while doing so. If an OCSP |
|
wtc
2011/06/03 01:58:04
Nit: just say "However, the call stalls the UI."
| |
| 42 certificates:reinterpret_cast<NSArray*>(certificates.get()) | 42 // responder or CRL source is experiencing delays and/or is unreachable, |
| 43 showGroup:YES]; | 43 // this may cause long stalls in the UI. By disabling revocation checking, |
| 44 // the intent is to minimize these stalls to the lesser of the evils, which | |
| 45 // is the time taken for path building and verification, which should be | |
| 46 // optimized based on the certificates supplied in |certificates|. This does | |
| 47 // not affect normal revocation checking, which is controlled by | |
| 48 // net::X509Certificate::Verify() and user preferences, so revoked | |
| 49 // certificates will still be processed. This does, however, prevent the UI | |
| 50 // from displaying which certificate in the chain was the revoked | |
| 51 // certificate if net::X509Certificate::Verify() had previously been called | |
| 52 // with revocation checking enabled. For the time being, this is an | |
|
wtc
2011/06/03 01:58:04
Nit: remove "For the time being".
(This comment b
| |
| 53 // acceptable trade-off. | |
| 54 base::mac::ScopedCFTypeRef<CFMutableArrayRef> policies( | |
| 55 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); | |
| 56 if (!policies.get()) { | |
| 57 NOTREACHED(); | |
| 58 return; | |
| 59 } | |
| 60 OSStatus status = | |
| 61 net::X509Certificate::CreateRevocationPolicies(false, policies); | |
| 62 | |
| 63 // In addition to revocation policies, it's necessary to re-add the basic | |
| 64 // X.509 policy that the SFCertificatePanel applies when no policies are | |
| 65 // explicitly provided. Because only the base X.509 policy is applied, | |
| 66 // any errors that are specific to SSL (such as invalid EKU or mismatched | |
| 67 // hostname and name identifiers) will not be displayed in the certificate | |
|
wtc
2011/06/03 01:58:04
Nit: just say "certificate name mismatch". "name
| |
| 68 // viewer if the user is viewing an SSL server certificate. | |
|
wtc
2011/06/03 01:58:04
Does the ordering of the policies matter? I wonde
Ryan Sleevi
2011/06/21 03:52:25
Functionally, it doesn't, but I went ahead and mad
| |
| 69 if (!status) { | |
|
wtc
2011/06/03 01:58:04
Nit: use
if (status == noErr)
and
if (status !
| |
| 70 SecPolicyRef basic_policy = NULL; | |
| 71 status = net::X509Certificate::CreateBasicX509Policy(&basic_policy); | |
| 72 if (!status) { | |
| 73 CFArrayAppendValue(policies, basic_policy); | |
| 74 CFRelease(basic_policy); | |
| 75 } | |
| 76 } | |
| 77 if (status) { | |
| 78 NOTREACHED(); | |
| 79 return; | |
| 80 } | |
| 81 | |
| 82 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; | |
| 83 [panel setPolicies:(id)policies.get()]; | |
| 84 [panel beginSheetForWindow:parent | |
| 85 modalDelegate:nil | |
| 86 didEndSelector:NULL | |
| 87 contextInfo:NULL | |
| 88 certificates:reinterpret_cast<NSArray*>(certificates.get()) | |
| 89 showGroup:YES]; | |
| 44 // The SFCertificatePanel releases itself when the sheet is dismissed. | 90 // The SFCertificatePanel releases itself when the sheet is dismissed. |
| 45 } | 91 } |
| OLD | NEW |