| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
| 6 | 6 |
| 7 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 7 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 8 // until NSS 3.12.2 comes out and we update to it. | 8 // until NSS 3.12.2 comes out and we update to it. |
| 9 #define Lock FOO_NSS_Lock | 9 #define Lock FOO_NSS_Lock |
| 10 #include <cert.h> | 10 #include <cert.h> |
| 11 #include <prtime.h> | 11 #include <prtime.h> |
| 12 #include <secder.h> | 12 #include <secder.h> |
| 13 #include <sechash.h> | 13 #include <sechash.h> |
| 14 #undef Lock | 14 #undef Lock |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/nss_init.h" | 18 #include "base/nss_init.h" |
| 19 #include "net/base/net_errors.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // TODO(port): Implement this more simply, and put it in the right place | 25 // TODO(port): Implement this more simply, and put it in the right place |
| 25 base::Time PRTimeToBaseTime(PRTime prtime) { | 26 base::Time PRTimeToBaseTime(PRTime prtime) { |
| 26 PRExplodedTime prxtime; | 27 PRExplodedTime prxtime; |
| 27 PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime); | 28 PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime); |
| 28 | 29 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 GetCertSubjectAltNamesOfType(cert_handle_, certDNSName, dns_names); | 193 GetCertSubjectAltNamesOfType(cert_handle_, certDNSName, dns_names); |
| 193 | 194 |
| 194 // TODO(port): suppress nss's support of the obsolete extension | 195 // TODO(port): suppress nss's support of the obsolete extension |
| 195 // SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME | 196 // SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME |
| 196 // by providing our own authCertificate callback. | 197 // by providing our own authCertificate callback. |
| 197 | 198 |
| 198 if (dns_names->empty()) | 199 if (dns_names->empty()) |
| 199 dns_names->push_back(subject_.common_name); | 200 dns_names->push_back(subject_.common_name); |
| 200 } | 201 } |
| 201 | 202 |
| 203 int X509Certificate::Verify(const std::string& hostname, |
| 204 bool rev_checking_enabled, |
| 205 CertVerifyResult* verify_result) const { |
| 206 NOTIMPLEMENTED(); |
| 207 return ERR_NOT_IMPLEMENTED; |
| 208 } |
| 209 |
| 202 // static | 210 // static |
| 203 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( | 211 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( |
| 204 const char* data, int length) { | 212 const char* data, int length) { |
| 205 base::EnsureNSSInit(); | 213 base::EnsureNSSInit(); |
| 206 | 214 |
| 207 SECItem der_cert; | 215 SECItem der_cert; |
| 208 der_cert.data = reinterpret_cast<unsigned char*>(const_cast<char*>(data)); | 216 der_cert.data = reinterpret_cast<unsigned char*>(const_cast<char*>(data)); |
| 209 der_cert.len = length; | 217 der_cert.len = length; |
| 210 return CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert, | 218 return CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert, |
| 211 NULL, PR_FALSE, PR_TRUE); | 219 NULL, PR_FALSE, PR_TRUE); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 227 | 235 |
| 228 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, | 236 SECStatus rv = HASH_HashBuf(HASH_AlgSHA1, sha1.data, |
| 229 cert->derCert.data, cert->derCert.len); | 237 cert->derCert.data, cert->derCert.len); |
| 230 DCHECK(rv == SECSuccess); | 238 DCHECK(rv == SECSuccess); |
| 231 | 239 |
| 232 return sha1; | 240 return sha1; |
| 233 } | 241 } |
| 234 | 242 |
| 235 } // namespace net | 243 } // namespace net |
| 236 | 244 |
| OLD | NEW |