OLD | NEW |
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 "net/base/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
8 #include <openssl/crypto.h> | 8 #include <openssl/crypto.h> |
9 #include <openssl/obj_mac.h> | 9 #include <openssl/obj_mac.h> |
10 #include <openssl/pem.h> | 10 #include <openssl/pem.h> |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 ip_addrs->clear(); | 418 ip_addrs->clear(); |
419 | 419 |
420 ParseSubjectAltName(cert_handle_, dns_names, ip_addrs); | 420 ParseSubjectAltName(cert_handle_, dns_names, ip_addrs); |
421 } | 421 } |
422 | 422 |
423 // static | 423 // static |
424 X509_STORE* X509Certificate::cert_store() { | 424 X509_STORE* X509Certificate::cert_store() { |
425 return X509InitSingleton::GetInstance()->store(); | 425 return X509InitSingleton::GetInstance()->store(); |
426 } | 426 } |
427 | 427 |
| 428 #if !defined(OS_ANDROID) |
| 429 |
428 int X509Certificate::VerifyInternal(const std::string& hostname, | 430 int X509Certificate::VerifyInternal(const std::string& hostname, |
429 int flags, | 431 int flags, |
430 CertVerifyResult* verify_result) const { | 432 CertVerifyResult* verify_result) const { |
431 if (!VerifyNameMatch(hostname)) | 433 if (!VerifyNameMatch(hostname)) |
432 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID; | 434 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID; |
433 | 435 |
434 crypto::ScopedOpenSSL<X509_STORE_CTX, X509_STORE_CTX_free> ctx( | 436 crypto::ScopedOpenSSL<X509_STORE_CTX, X509_STORE_CTX_free> ctx( |
435 X509_STORE_CTX_new()); | 437 X509_STORE_CTX_new()); |
436 | 438 |
437 crypto::ScopedOpenSSL<STACK_OF(X509), sk_X509_free_fn> intermediates( | 439 crypto::ScopedOpenSSL<STACK_OF(X509), sk_X509_free_fn> intermediates( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // Currently we only ues OpenSSL's default root CA paths, so treat all | 499 // Currently we only ues OpenSSL's default root CA paths, so treat all |
498 // correctly verified certs as being from a known root. TODO(joth): if the | 500 // correctly verified certs as being from a known root. TODO(joth): if the |
499 // motivations described in http://src.chromium.org/viewvc/chrome?view=rev&rev
ision=80778 | 501 // motivations described in http://src.chromium.org/viewvc/chrome?view=rev&rev
ision=80778 |
500 // become an issue on OpenSSL builds, we will need to embed a hardcoded list | 502 // become an issue on OpenSSL builds, we will need to embed a hardcoded list |
501 // of well known root CAs, as per the _mac and _win versions. | 503 // of well known root CAs, as per the _mac and _win versions. |
502 verify_result->is_issued_by_known_root = true; | 504 verify_result->is_issued_by_known_root = true; |
503 | 505 |
504 return OK; | 506 return OK; |
505 } | 507 } |
506 | 508 |
| 509 #endif // !defined(OS_ANDROID) |
| 510 |
507 bool X509Certificate::GetDEREncoded(std::string* encoded) { | 511 bool X509Certificate::GetDEREncoded(std::string* encoded) { |
508 DERCache der_cache; | 512 DERCache der_cache; |
509 if (!GetDERAndCacheIfNeeded(cert_handle_, &der_cache)) | 513 if (!GetDERAndCacheIfNeeded(cert_handle_, &der_cache)) |
510 return false; | 514 return false; |
511 encoded->assign(reinterpret_cast<const char*>(der_cache.data), | 515 encoded->assign(reinterpret_cast<const char*>(der_cache.data), |
512 der_cache.data_length); | 516 der_cache.data_length); |
513 return true; | 517 return true; |
514 } | 518 } |
515 | 519 |
516 // static | 520 // static |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 DERCache der_cache; | 553 DERCache der_cache; |
550 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache)) | 554 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache)) |
551 return false; | 555 return false; |
552 | 556 |
553 return pickle->WriteData( | 557 return pickle->WriteData( |
554 reinterpret_cast<const char*>(der_cache.data), | 558 reinterpret_cast<const char*>(der_cache.data), |
555 der_cache.data_length); | 559 der_cache.data_length); |
556 } | 560 } |
557 | 561 |
558 } // namespace net | 562 } // namespace net |
OLD | NEW |