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 #define PRArenaPool PLArenaPool // Required by <blapi.h>. | 7 #define PRArenaPool PLArenaPool // Required by <blapi.h>. |
8 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. | 8 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 550 |
551 void X509Certificate::Initialize() { | 551 void X509Certificate::Initialize() { |
552 std::wstring subject_info; | 552 std::wstring subject_info; |
553 std::wstring issuer_info; | 553 std::wstring issuer_info; |
554 DWORD name_size; | 554 DWORD name_size; |
555 DCHECK(cert_handle_); | 555 DCHECK(cert_handle_); |
556 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, | 556 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, |
557 &cert_handle_->pCertInfo->Subject, | 557 &cert_handle_->pCertInfo->Subject, |
558 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, | 558 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, |
559 NULL, 0); | 559 NULL, 0); |
560 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, | 560 if (name_size > 1) { |
561 &cert_handle_->pCertInfo->Subject, | 561 CertNameToStr(cert_handle_->dwCertEncodingType, |
562 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, | 562 &cert_handle_->pCertInfo->Subject, |
563 WriteInto(&subject_info, name_size), name_size); | 563 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, |
| 564 WriteInto(&subject_info, name_size), name_size); |
| 565 } |
564 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, | 566 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, |
565 &cert_handle_->pCertInfo->Issuer, | 567 &cert_handle_->pCertInfo->Issuer, |
566 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, | 568 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, |
567 NULL, 0); | 569 NULL, 0); |
568 name_size = CertNameToStr(cert_handle_->dwCertEncodingType, | 570 if (name_size > 1) { |
569 &cert_handle_->pCertInfo->Issuer, | 571 CertNameToStr(cert_handle_->dwCertEncodingType, |
570 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, | 572 &cert_handle_->pCertInfo->Issuer, |
571 WriteInto(&issuer_info, name_size), name_size); | 573 CERT_X500_NAME_STR | CERT_NAME_STR_CRLF_FLAG, |
| 574 WriteInto(&issuer_info, name_size), name_size); |
| 575 } |
572 ParsePrincipal(WideToUTF8(subject_info), &subject_); | 576 ParsePrincipal(WideToUTF8(subject_info), &subject_); |
573 ParsePrincipal(WideToUTF8(issuer_info), &issuer_); | 577 ParsePrincipal(WideToUTF8(issuer_info), &issuer_); |
574 | 578 |
575 valid_start_ = Time::FromFileTime(cert_handle_->pCertInfo->NotBefore); | 579 valid_start_ = Time::FromFileTime(cert_handle_->pCertInfo->NotBefore); |
576 valid_expiry_ = Time::FromFileTime(cert_handle_->pCertInfo->NotAfter); | 580 valid_expiry_ = Time::FromFileTime(cert_handle_->pCertInfo->NotAfter); |
577 | 581 |
578 fingerprint_ = CalculateFingerprint(cert_handle_); | 582 fingerprint_ = CalculateFingerprint(cert_handle_); |
579 ca_fingerprint_ = CalculateCAFingerprint(intermediate_ca_certs_); | 583 ca_fingerprint_ = CalculateCAFingerprint(intermediate_ca_certs_); |
580 | 584 |
581 const CRYPT_INTEGER_BLOB* serial = &cert_handle_->pCertInfo->SerialNumber; | 585 const CRYPT_INTEGER_BLOB* serial = &cert_handle_->pCertInfo->SerialNumber; |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], | 1151 if (!CertSerializeCertificateStoreElement(cert_handle, 0, &buffer[0], |
1148 &length)) { | 1152 &length)) { |
1149 return false; | 1153 return false; |
1150 } | 1154 } |
1151 | 1155 |
1152 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), | 1156 return pickle->WriteData(reinterpret_cast<const char*>(&buffer[0]), |
1153 length); | 1157 length); |
1154 } | 1158 } |
1155 | 1159 |
1156 } // namespace net | 1160 } // namespace net |
OLD | NEW |