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

Side by Side Diff: net/cert/x509_util_ios_and_mac.cc

Issue 2864133002: Convert iOS to use X509CertificateBytes. (Closed)
Patch Set: static_cast, more unittest Created 3 years, 7 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
« no previous file with comments | « net/cert/x509_util_ios_and_mac.h ('k') | net/cert/x509_util_ios_and_mac_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/cert/x509_util_ios_and_mac.h"
6
7 #include "net/cert/x509_certificate.h"
8 #if defined(OS_IOS)
9 #include "net/cert/x509_util_ios.h"
10 #else
11 #include "net/cert/x509_util_mac.h"
12 #endif
13 #include "third_party/boringssl/src/include/openssl/pool.h"
14
15 namespace net {
16
17 namespace x509_util {
18
19 base::ScopedCFTypeRef<CFMutableArrayRef>
20 CreateSecCertificateArrayForX509Certificate(X509Certificate* cert) {
21 base::ScopedCFTypeRef<CFMutableArrayRef> cert_list(
22 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
23 if (!cert_list)
24 return base::ScopedCFTypeRef<CFMutableArrayRef>();
25 #if BUILDFLAG(USE_BYTE_CERTS)
26 std::string bytes;
27 base::ScopedCFTypeRef<SecCertificateRef> sec_cert(
28 CreateSecCertificateFromBytes(CRYPTO_BUFFER_data(cert->os_cert_handle()),
29 CRYPTO_BUFFER_len(cert->os_cert_handle())));
30 if (!sec_cert)
31 return base::ScopedCFTypeRef<CFMutableArrayRef>();
32 CFArrayAppendValue(cert_list, sec_cert);
33 for (X509Certificate::OSCertHandle intermediate :
34 cert->GetIntermediateCertificates()) {
35 base::ScopedCFTypeRef<SecCertificateRef> sec_cert(
36 CreateSecCertificateFromBytes(CRYPTO_BUFFER_data(intermediate),
37 CRYPTO_BUFFER_len(intermediate)));
38 if (!sec_cert)
39 return base::ScopedCFTypeRef<CFMutableArrayRef>();
40 CFArrayAppendValue(cert_list, sec_cert);
41 }
42 #else
43 X509Certificate::OSCertHandles intermediate_ca_certs =
44 cert->GetIntermediateCertificates();
45 CFArrayAppendValue(cert_list, cert->os_cert_handle());
46 for (size_t i = 0; i < intermediate_ca_certs.size(); ++i)
47 CFArrayAppendValue(cert_list, intermediate_ca_certs[i]);
48 #endif
49 return cert_list;
50 }
51
52 } // namespace x509_util
53
54 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_util_ios_and_mac.h ('k') | net/cert/x509_util_ios_and_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698