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

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: Mac fix Created 9 years, 2 months 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
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 #include "net/base/x509_util_mac.h"
15 16
16 void ShowCertificateViewer(gfx::NativeWindow parent, 17 void ShowCertificateViewer(gfx::NativeWindow parent,
17 net::X509Certificate* cert) { 18 net::X509Certificate* cert) {
18 SecCertificateRef cert_mac = cert->os_cert_handle(); 19 base::mac::ScopedCFTypeRef<CFArrayRef> cert_list(
19 if (!cert_mac) 20 net::x509_util::CreateOSCertChainForCert(cert));
20 return; 21 NSArray* certificates = base::mac::CFToNSCast(cert_list.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 22
37 // Explicitly disable revocation checking, regardless of user preferences 23 // Explicitly disable revocation checking, regardless of user preferences
38 // or system settings. The behaviour of SFCertificatePanel is to call 24 // or system settings. The behaviour of SFCertificatePanel is to call
39 // SecTrustEvaluate on the certificate(s) supplied, effectively 25 // SecTrustEvaluate on the certificate(s) supplied, effectively
40 // duplicating the behaviour of net::X509Certificate::Verify(). However, 26 // duplicating the behaviour of net::X509Certificate::Verify(). However,
41 // this call stalls the UI if revocation checking is enabled in the 27 // 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 28 // 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 29 // revocation checking, the stall is limited to the time taken for path
44 // building and verification, which should be minimized due to the path 30 // building and verification, which should be minimized due to the path
45 // being provided in |certificates|. This does not affect normal 31 // being provided in |certificates|. This does not affect normal
(...skipping 24 matching lines...) Expand all
70 NOTREACHED(); 56 NOTREACHED();
71 return; 57 return;
72 } 58 }
73 59
74 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init]; 60 SFCertificatePanel* panel = [[SFCertificatePanel alloc] init];
75 [panel setPolicies:(id)policies.get()]; 61 [panel setPolicies:(id)policies.get()];
76 [panel beginSheetForWindow:parent 62 [panel beginSheetForWindow:parent
77 modalDelegate:nil 63 modalDelegate:nil
78 didEndSelector:NULL 64 didEndSelector:NULL
79 contextInfo:NULL 65 contextInfo:NULL
80 certificates:reinterpret_cast<NSArray*>(certificates.get()) 66 certificates:certificates
81 showGroup:YES]; 67 showGroup:YES];
82 // The SFCertificatePanel releases itself when the sheet is dismissed. 68 // The SFCertificatePanel releases itself when the sheet is dismissed.
83 } 69 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/certificate_viewer_win.cc » ('j') | chrome/browser/ui/views/certificate_viewer_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698