Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chrome/browser/ui/cocoa/certificate_viewer.mm

Issue 7324039: Ensure X509Certificate::OSCertHandles are safe to be used on both UI and IO threads on Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/certificate_viewer_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
11 11
12 #include "base/logging.h" 12 #include "base/mac/foundation_util.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "net/base/x509_certificate.h" 14 #include "net/base/x509_certificate.h"
15 15
16 void ShowCertificateViewer(gfx::NativeWindow parent, 16 void ShowCertificateViewer(gfx::NativeWindow parent,
17 net::X509Certificate* cert) { 17 net::X509Certificate* cert) {
18 SecCertificateRef cert_mac = cert->os_cert_handle(); 18 base::mac::ScopedCFTypeRef<CFArrayRef> cert_chain(
19 if (!cert_mac) 19 cert->CreateOSCertChainForCert());
20 return; 20 NSArray* certificates = base::mac::CFToNSCast(cert_chain.get());
21
22 base::mac::ScopedCFTypeRef<CFMutableArrayRef> certificates(
23 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
24 if (!certificates.get()) {
25 NOTREACHED();
26 return;
27 }
28 CFArrayAppendValue(certificates, cert_mac);
29
30 // Server certificate must be first in the array; subsequent certificates
31 // in the chain can be in any order.
32 const std::vector<SecCertificateRef>& ca_certs =
33 cert->GetIntermediateCertificates();
34 for (size_t i = 0; i < ca_certs.size(); ++i)
35 CFArrayAppendValue(certificates, ca_certs[i]);
36 21
37 // Explicitly disable revocation checking, regardless of user preferences 22 // Explicitly disable revocation checking, regardless of user preferences
38 // or system settings. The behaviour of SFCertificatePanel is to call 23 // or system settings. The behaviour of SFCertificatePanel is to call
39 // SecTrustEvaluate on the certificate(s) supplied, effectively 24 // SecTrustEvaluate on the certificate(s) supplied, effectively
40 // duplicating the behaviour of net::X509Certificate::Verify(). However, 25 // duplicating the behaviour of net::X509Certificate::Verify(). However,
41 // this call stalls the UI if revocation checking is enabled in the 26 // this call stalls the UI if revocation checking is enabled in the
42 // Keychain preferences or if the cert may be an EV cert. By disabling 27 // Keychain preferences or if the cert may be an EV cert. By disabling
43 // revocation checking, the stall is limited to the time taken for path 28 // revocation checking, the stall is limited to the time taken for path
44 // building and verification, which should be minimized due to the path 29 // building and verification, which should be minimized due to the path
45 // being provided in |certificates|. This does not affect normal 30 // being provided in |certificates|. This does not affect normal
(...skipping 24 matching lines...) Expand all
70 NOTREACHED(); 55 NOTREACHED();
71 return; 56 return;
72 } 57 }
73 58
74 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; 59 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init];
75 [panel setPolicies:(id)policies.get()]; 60 [panel setPolicies:(id)policies.get()];
76 [panel beginSheetForWindow:parent 61 [panel beginSheetForWindow:parent
77 modalDelegate:nil 62 modalDelegate:nil
78 didEndSelector:NULL 63 didEndSelector:NULL
79 contextInfo:NULL 64 contextInfo:NULL
80 certificates:reinterpret_cast<NSArray*>(certificates.get()) 65 certificates:certificates
81 showGroup:YES]; 66 showGroup:YES];
82 // The SFCertificatePanel releases itself when the sheet is dismissed. 67 // The SFCertificatePanel releases itself when the sheet is dismissed.
83 } 68 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/certificate_viewer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698