OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <Security/Security.h> | 8 #include <Security/Security.h> |
9 | 9 |
10 #include <cert.h> | 10 #include <cert.h> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (ip_addrs) | 96 if (ip_addrs) |
97 ip_addrs->clear(); | 97 ip_addrs->clear(); |
98 return; | 98 return; |
99 } | 99 } |
100 x509_util::GetSubjectAltName(cert_handle, dns_names, ip_addrs); | 100 x509_util::GetSubjectAltName(cert_handle, dns_names, ip_addrs); |
101 } | 101 } |
102 | 102 |
103 // static | 103 // static |
104 bool X509Certificate::GetDEREncoded(OSCertHandle cert_handle, | 104 bool X509Certificate::GetDEREncoded(OSCertHandle cert_handle, |
105 std::string* encoded) { | 105 std::string* encoded) { |
| 106 if (!cert_handle) |
| 107 return false; |
106 ScopedCFTypeRef<CFDataRef> der_data(SecCertificateCopyData(cert_handle)); | 108 ScopedCFTypeRef<CFDataRef> der_data(SecCertificateCopyData(cert_handle)); |
107 if (!der_data) | 109 if (!der_data) |
108 return false; | 110 return false; |
109 encoded->assign(reinterpret_cast<const char*>(CFDataGetBytePtr(der_data)), | 111 encoded->assign(reinterpret_cast<const char*>(CFDataGetBytePtr(der_data)), |
110 CFDataGetLength(der_data)); | 112 CFDataGetLength(der_data)); |
111 return true; | 113 return true; |
112 } | 114 } |
113 | 115 |
114 // static | 116 // static |
115 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, | 117 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 228 |
227 // static | 229 // static |
228 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 230 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
229 size_t* size_bits, | 231 size_t* size_bits, |
230 PublicKeyType* type) { | 232 PublicKeyType* type) { |
231 x509_util_ios::NSSCertificate nss_cert(cert_handle); | 233 x509_util_ios::NSSCertificate nss_cert(cert_handle); |
232 x509_util::GetPublicKeyInfo(nss_cert.cert_handle(), size_bits, type); | 234 x509_util::GetPublicKeyInfo(nss_cert.cert_handle(), size_bits, type); |
233 } | 235 } |
234 | 236 |
235 } // namespace net | 237 } // namespace net |
OLD | NEW |