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

Side by Side Diff: net/base/cert_test_util.cc

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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
« no previous file with comments | « gfx/canvas_skia_mac.mm ('k') | net/base/keygen_handler_mac.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) 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 "net/base/cert_test_util.h" 5 #include "net/base/cert_test_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(USE_OPENSSL) 9 #if defined(USE_OPENSSL)
10 #include <openssl/err.h> 10 #include <openssl/err.h>
11 #include <openssl/x509v3.h> 11 #include <openssl/x509v3.h>
12 #include "net/base/openssl_util.h" 12 #include "net/base/openssl_util.h"
13 #elif defined(USE_NSS) 13 #elif defined(USE_NSS)
14 #include <cert.h> 14 #include <cert.h>
15 #include "base/nss_util.h" 15 #include "base/nss_util.h"
16 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX)
17 #include <Security/Security.h> 17 #include <Security/Security.h>
18 #include "base/scoped_cftyperef.h" 18 #include "base/mac/scoped_cftyperef.h"
19 #endif 19 #endif
20 20
21 #include "base/file_util.h" 21 #include "base/file_util.h"
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "net/base/x509_certificate.h" 24 #include "net/base/x509_certificate.h"
25 25
26 namespace net { 26 namespace net {
27 27
28 #if defined(USE_OPENSSL) 28 #if defined(USE_OPENSSL)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (!file_util::ReadFileToString(filename, &rawcert)) { 97 if (!file_util::ReadFileToString(filename, &rawcert)) {
98 LOG(ERROR) << "Can't load certificate " << filename.value(); 98 LOG(ERROR) << "Can't load certificate " << filename.value();
99 return NULL; 99 return NULL;
100 } 100 }
101 101
102 CFDataRef pem = CFDataCreate(kCFAllocatorDefault, 102 CFDataRef pem = CFDataCreate(kCFAllocatorDefault,
103 reinterpret_cast<const UInt8*>(rawcert.data()), 103 reinterpret_cast<const UInt8*>(rawcert.data()),
104 static_cast<CFIndex>(rawcert.size())); 104 static_cast<CFIndex>(rawcert.size()));
105 if (!pem) 105 if (!pem)
106 return NULL; 106 return NULL;
107 scoped_cftyperef<CFDataRef> scoped_pem(pem); 107 base::mac::ScopedCFTypeRef<CFDataRef> scoped_pem(pem);
108 108
109 SecExternalFormat input_format = kSecFormatUnknown; 109 SecExternalFormat input_format = kSecFormatUnknown;
110 SecExternalItemType item_type = kSecItemTypeUnknown; 110 SecExternalItemType item_type = kSecItemTypeUnknown;
111 CFArrayRef cert_array = NULL; 111 CFArrayRef cert_array = NULL;
112 if (SecKeychainItemImport(pem, NULL, &input_format, &item_type, 0, NULL, NULL, 112 if (SecKeychainItemImport(pem, NULL, &input_format, &item_type, 0, NULL, NULL,
113 &cert_array)) 113 &cert_array))
114 return NULL; 114 return NULL;
115 scoped_cftyperef<CFArrayRef> scoped_cert_array(cert_array); 115 base::mac::ScopedCFTypeRef<CFArrayRef> scoped_cert_array(cert_array);
116 116
117 if (!CFArrayGetCount(cert_array)) 117 if (!CFArrayGetCount(cert_array))
118 return NULL; 118 return NULL;
119 119
120 SecCertificateRef cert_ref = static_cast<SecCertificateRef>( 120 SecCertificateRef cert_ref = static_cast<SecCertificateRef>(
121 const_cast<void*>(CFArrayGetValueAtIndex(cert_array, 0))); 121 const_cast<void*>(CFArrayGetValueAtIndex(cert_array, 0)));
122 122
123 return X509Certificate::CreateFromHandle(cert_ref, 123 return X509Certificate::CreateFromHandle(cert_ref,
124 X509Certificate::SOURCE_LONE_CERT_IMPORT, 124 X509Certificate::SOURCE_LONE_CERT_IMPORT,
125 X509Certificate::OSCertHandles()); 125 X509Certificate::OSCertHandles());
126 } 126 }
127 #endif 127 #endif
128 128
129 } // namespace net 129 } // namespace net
OLDNEW
« no previous file with comments | « gfx/canvas_skia_mac.mm ('k') | net/base/keygen_handler_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698