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

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

Issue 7538029: Upstream certificate and mime Android implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DEPS Created 9 years, 4 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
OLDNEW
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 ip_addrs->clear(); 417 ip_addrs->clear();
418 418
419 ParseSubjectAltName(cert_handle_, dns_names, ip_addrs); 419 ParseSubjectAltName(cert_handle_, dns_names, ip_addrs);
420 } 420 }
421 421
422 // static 422 // static
423 X509_STORE* X509Certificate::cert_store() { 423 X509_STORE* X509Certificate::cert_store() {
424 return X509InitSingleton::GetInstance()->store(); 424 return X509InitSingleton::GetInstance()->store();
425 } 425 }
426 426
427 #if !defined(OS_ANDROID)
428
427 int X509Certificate::VerifyInternal(const std::string& hostname, 429 int X509Certificate::VerifyInternal(const std::string& hostname,
428 int flags, 430 int flags,
429 CertVerifyResult* verify_result) const { 431 CertVerifyResult* verify_result) const {
430 if (!VerifyNameMatch(hostname)) 432 if (!VerifyNameMatch(hostname))
431 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID; 433 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID;
432 434
433 crypto::ScopedOpenSSL<X509_STORE_CTX, X509_STORE_CTX_free> ctx( 435 crypto::ScopedOpenSSL<X509_STORE_CTX, X509_STORE_CTX_free> ctx(
434 X509_STORE_CTX_new()); 436 X509_STORE_CTX_new());
435 437
436 crypto::ScopedOpenSSL<STACK_OF(X509), sk_X509_free_fn> intermediates( 438 crypto::ScopedOpenSSL<STACK_OF(X509), sk_X509_free_fn> intermediates(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // Currently we only ues OpenSSL's default root CA paths, so treat all 498 // Currently we only ues OpenSSL's default root CA paths, so treat all
497 // correctly verified certs as being from a known root. TODO(joth): if the 499 // correctly verified certs as being from a known root. TODO(joth): if the
498 // motivations described in http://src.chromium.org/viewvc/chrome?view=rev&rev ision=80778 500 // motivations described in http://src.chromium.org/viewvc/chrome?view=rev&rev ision=80778
499 // become an issue on OpenSSL builds, we will need to embed a hardcoded list 501 // become an issue on OpenSSL builds, we will need to embed a hardcoded list
500 // of well known root CAs, as per the _mac and _win versions. 502 // of well known root CAs, as per the _mac and _win versions.
501 verify_result->is_issued_by_known_root = true; 503 verify_result->is_issued_by_known_root = true;
502 504
503 return OK; 505 return OK;
504 } 506 }
505 507
508 #endif // !OS_ANDROID
wtc 2011/08/09 18:47:22 !OS_ANDROID => !defined(OS_ANDROID)
michaelbai 2011/08/11 16:10:18 Done.
509
506 bool X509Certificate::GetDEREncoded(std::string* encoded) { 510 bool X509Certificate::GetDEREncoded(std::string* encoded) {
507 DERCache der_cache; 511 DERCache der_cache;
508 if (!GetDERAndCacheIfNeeded(cert_handle_, &der_cache)) 512 if (!GetDERAndCacheIfNeeded(cert_handle_, &der_cache))
509 return false; 513 return false;
510 encoded->assign(reinterpret_cast<const char*>(der_cache.data), 514 encoded->assign(reinterpret_cast<const char*>(der_cache.data),
511 der_cache.data_length); 515 der_cache.data_length);
512 return true; 516 return true;
513 } 517 }
514 518
515 // static 519 // static
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 DERCache der_cache; 552 DERCache der_cache;
549 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache)) 553 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache))
550 return false; 554 return false;
551 555
552 return pickle->WriteData( 556 return pickle->WriteData(
553 reinterpret_cast<const char*>(der_cache.data), 557 reinterpret_cast<const char*>(der_cache.data),
554 der_cache.data_length); 558 der_cache.data_length);
555 } 559 }
556 560
557 } // namespace net 561 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698