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

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

Issue 4645001: Change the HTTP cache to cache the entire certificate chain for SSL sites (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Rebase before commit Created 9 years, 8 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 default: { 378 default: {
379 NOTREACHED() << "Certificate format " << format << " unimplemented"; 379 NOTREACHED() << "Certificate format " << format << " unimplemented";
380 break; 380 break;
381 } 381 }
382 } 382 }
383 383
384 return results; 384 return results;
385 } 385 }
386 386
387 // static 387 // static
388 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle,
389 void** pickle_iter) {
390 const char* data;
391 int length;
392 if (!pickle.ReadData(pickle_iter, &data, &length))
393 return NULL;
394
395 return CreateFromBytes(data, length);
396 }
397
398 // static
399 X509Certificate* X509Certificate::CreateSelfSigned( 388 X509Certificate* X509Certificate::CreateSelfSigned(
400 crypto::RSAPrivateKey* key, 389 crypto::RSAPrivateKey* key,
401 const std::string& subject, 390 const std::string& subject,
402 uint32 serial_number, 391 uint32 serial_number,
403 base::TimeDelta valid_duration) { 392 base::TimeDelta valid_duration) {
404 // TODO(port): Implement. 393 // TODO(port): Implement.
405 return NULL; 394 return NULL;
406 } 395 }
407 396
408 void X509Certificate::Persist(Pickle* pickle) {
409 DERCache der_cache;
410 if (!GetDERAndCacheIfNeeded(cert_handle_, &der_cache))
411 return;
412
413 pickle->WriteData(reinterpret_cast<const char*>(der_cache.data),
414 der_cache.data_length);
415 }
416
417 void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const { 397 void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const {
418 dns_names->clear(); 398 dns_names->clear();
419 399
420 ParseSubjectAltNames(cert_handle_, dns_names); 400 ParseSubjectAltNames(cert_handle_, dns_names);
421 401
422 if (dns_names->empty()) 402 if (dns_names->empty())
423 dns_names->push_back(subject_.common_name); 403 dns_names->push_back(subject_.common_name);
424 } 404 }
425 405
426 // static 406 // static
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // DER data. Encoding it from OSCertHandle is an expensive operation, so we 506 // DER data. Encoding it from OSCertHandle is an expensive operation, so we
527 // cache the DER (if not already cached via X509_set_ex_data). 507 // cache the DER (if not already cached via X509_set_ex_data).
528 DERCache der_cache_a, der_cache_b; 508 DERCache der_cache_a, der_cache_b;
529 509
530 return GetDERAndCacheIfNeeded(a, &der_cache_a) && 510 return GetDERAndCacheIfNeeded(a, &der_cache_a) &&
531 GetDERAndCacheIfNeeded(b, &der_cache_b) && 511 GetDERAndCacheIfNeeded(b, &der_cache_b) &&
532 der_cache_a.data_length == der_cache_b.data_length && 512 der_cache_a.data_length == der_cache_b.data_length &&
533 memcmp(der_cache_a.data, der_cache_b.data, der_cache_a.data_length) == 0; 513 memcmp(der_cache_a.data, der_cache_b.data, der_cache_a.data_length) == 0;
534 } 514 }
535 515
516 // static
517 X509Certificate::OSCertHandle
518 X509Certificate::ReadCertHandleFromPickle(const Pickle& pickle,
519 void** pickle_iter) {
520 const char* data;
521 int length;
522 if (!pickle.ReadData(pickle_iter, &data, &length))
523 return NULL;
524
525 return CreateOSCertHandleFromBytes(data, length);
526 }
527
528 // static
529 bool X509Certificate::WriteCertHandleToPickle(OSCertHandle cert_handle,
530 Pickle* pickle) {
531 DERCache der_cache;
532 if (!GetDERAndCacheIfNeeded(cert_handle, &der_cache))
533 return false;
534
535 return pickle->WriteData(
536 reinterpret_cast<const char*>(der_cache.data),
537 der_cache.data_length);
538 }
539
536 } // namespace net 540 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698