OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. | 7 #include <blapi.h> // Implement CalculateChainFingerprint() with NSS. |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 system_time->wHour = exploded.hour; | 38 system_time->wHour = exploded.hour; |
39 system_time->wMinute = exploded.minute; | 39 system_time->wMinute = exploded.minute; |
40 system_time->wSecond = exploded.second; | 40 system_time->wSecond = exploded.second; |
41 system_time->wMilliseconds = exploded.millisecond; | 41 system_time->wMilliseconds = exploded.millisecond; |
42 } | 42 } |
43 | 43 |
44 //----------------------------------------------------------------------------- | 44 //----------------------------------------------------------------------------- |
45 | 45 |
46 // Decodes the cert's subjectAltName extension into a CERT_ALT_NAME_INFO | 46 // Decodes the cert's subjectAltName extension into a CERT_ALT_NAME_INFO |
47 // structure and stores it in *output. | 47 // structure and stores it in *output. |
48 void GetCertSubjectAltName(PCCERT_CONTEXT cert, | 48 void GetCertSubjectAltName( |
49 scoped_ptr_malloc<CERT_ALT_NAME_INFO>* output) { | 49 PCCERT_CONTEXT cert, |
| 50 scoped_ptr<CERT_ALT_NAME_INFO, base::FreeDeleter>* output) { |
50 PCERT_EXTENSION extension = CertFindExtension(szOID_SUBJECT_ALT_NAME2, | 51 PCERT_EXTENSION extension = CertFindExtension(szOID_SUBJECT_ALT_NAME2, |
51 cert->pCertInfo->cExtension, | 52 cert->pCertInfo->cExtension, |
52 cert->pCertInfo->rgExtension); | 53 cert->pCertInfo->rgExtension); |
53 if (!extension) | 54 if (!extension) |
54 return; | 55 return; |
55 | 56 |
56 CRYPT_DECODE_PARA decode_para; | 57 CRYPT_DECODE_PARA decode_para; |
57 decode_para.cbSize = sizeof(decode_para); | 58 decode_para.cbSize = sizeof(decode_para); |
58 decode_para.pfnAlloc = crypto::CryptAlloc; | 59 decode_para.pfnAlloc = crypto::CryptAlloc; |
59 decode_para.pfnFree = crypto::CryptFree; | 60 decode_para.pfnFree = crypto::CryptFree; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 std::vector<std::string>* dns_names, | 169 std::vector<std::string>* dns_names, |
169 std::vector<std::string>* ip_addrs) const { | 170 std::vector<std::string>* ip_addrs) const { |
170 if (dns_names) | 171 if (dns_names) |
171 dns_names->clear(); | 172 dns_names->clear(); |
172 if (ip_addrs) | 173 if (ip_addrs) |
173 ip_addrs->clear(); | 174 ip_addrs->clear(); |
174 | 175 |
175 if (!cert_handle_) | 176 if (!cert_handle_) |
176 return; | 177 return; |
177 | 178 |
178 scoped_ptr_malloc<CERT_ALT_NAME_INFO> alt_name_info; | 179 scoped_ptr<CERT_ALT_NAME_INFO, base::FreeDeleter> alt_name_info; |
179 GetCertSubjectAltName(cert_handle_, &alt_name_info); | 180 GetCertSubjectAltName(cert_handle_, &alt_name_info); |
180 CERT_ALT_NAME_INFO* alt_name = alt_name_info.get(); | 181 CERT_ALT_NAME_INFO* alt_name = alt_name_info.get(); |
181 if (alt_name) { | 182 if (alt_name) { |
182 int num_entries = alt_name->cAltEntry; | 183 int num_entries = alt_name->cAltEntry; |
183 for (int i = 0; i < num_entries; i++) { | 184 for (int i = 0; i < num_entries; i++) { |
184 // dNSName is an ASN.1 IA5String representing a string of ASCII | 185 // dNSName is an ASN.1 IA5String representing a string of ASCII |
185 // characters, so we can use WideToASCII here. | 186 // characters, so we can use WideToASCII here. |
186 const CERT_ALT_NAME_ENTRY& entry = alt_name->rgAltEntry[i]; | 187 const CERT_ALT_NAME_ENTRY& entry = alt_name->rgAltEntry[i]; |
187 | 188 |
188 if (dns_names && entry.dwAltNameChoice == CERT_ALT_NAME_DNS_NAME) { | 189 if (dns_names && entry.dwAltNameChoice == CERT_ALT_NAME_DNS_NAME) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (IsCertNameBlobInIssuerList(&(*it)->pCertInfo->Issuer, | 445 if (IsCertNameBlobInIssuerList(&(*it)->pCertInfo->Issuer, |
445 valid_issuers)) { | 446 valid_issuers)) { |
446 return true; | 447 return true; |
447 } | 448 } |
448 } | 449 } |
449 | 450 |
450 return false; | 451 return false; |
451 } | 452 } |
452 | 453 |
453 } // namespace net | 454 } // namespace net |
OLD | NEW |