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/base/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <nss.h> | 10 #include <nss.h> |
11 #include <pk11pub.h> | 11 #include <pk11pub.h> |
12 #include <prtime.h> | 12 #include <prtime.h> |
13 #include <seccomon.h> | |
13 #include <secder.h> | 14 #include <secder.h> |
14 #include <sechash.h> | 15 #include <sechash.h> |
15 | 16 |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
18 #include "base/pickle.h" | 19 #include "base/pickle.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "crypto/nss_util.h" | 21 #include "crypto/nss_util.h" |
21 #include "crypto/rsa_private_key.h" | 22 #include "crypto/rsa_private_key.h" |
22 #include "net/base/x509_util_nss.h" | 23 #include "net/base/x509_util_nss.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 void X509Certificate::GetSubjectAltName( | 148 void X509Certificate::GetSubjectAltName( |
148 std::vector<std::string>* dns_names, | 149 std::vector<std::string>* dns_names, |
149 std::vector<std::string>* ip_addrs) const { | 150 std::vector<std::string>* ip_addrs) const { |
150 x509_util::GetSubjectAltName(cert_handle_, dns_names, ip_addrs); | 151 x509_util::GetSubjectAltName(cert_handle_, dns_names, ip_addrs); |
151 } | 152 } |
152 | 153 |
153 bool X509Certificate::VerifyNameMatch(const std::string& hostname) const { | 154 bool X509Certificate::VerifyNameMatch(const std::string& hostname) const { |
154 return CERT_VerifyCertName(cert_handle_, hostname.c_str()) == SECSuccess; | 155 return CERT_VerifyCertName(cert_handle_, hostname.c_str()) == SECSuccess; |
155 } | 156 } |
156 | 157 |
158 bool X509Certificate::IsIssuedByEncoded( | |
159 const std::vector<std::string>& valid_issuers) { | |
160 if (x509_util::IsCertNameItemInIssuerList(&cert_handle_->derIssuer, | |
161 valid_issuers)) | |
Ryan Sleevi
2012/12/13 19:49:05
STYLE: See comments re braces (also line 166-168)
| |
162 return true; | |
163 | |
164 for (OSCertHandles::iterator it = intermediate_ca_certs_.begin(); | |
165 it != intermediate_ca_certs_.end(); ++it) { | |
166 if (x509_util::IsCertNameItemInIssuerList(&(*it)->derSubject, | |
167 valid_issuers)) | |
Ryan Sleevi
2012/12/13 19:49:05
BUG: See comment in ios re subject vs issuer
| |
168 return true; | |
169 } | |
170 return false; | |
171 } | |
172 | |
157 // static | 173 // static |
158 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, | 174 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, |
159 std::string* encoded) { | 175 std::string* encoded) { |
160 if (!cert_handle->derCert.len) | 176 if (!cert_handle->derCert.len) |
161 return false; | 177 return false; |
162 encoded->assign(reinterpret_cast<char*>(cert_handle->derCert.data), | 178 encoded->assign(reinterpret_cast<char*>(cert_handle->derCert.data), |
163 cert_handle->derCert.len); | 179 cert_handle->derCert.len); |
164 return true; | 180 return true; |
165 } | 181 } |
166 | 182 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 } | 292 } |
277 | 293 |
278 // static | 294 // static |
279 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, | 295 void X509Certificate::GetPublicKeyInfo(OSCertHandle cert_handle, |
280 size_t* size_bits, | 296 size_t* size_bits, |
281 PublicKeyType* type) { | 297 PublicKeyType* type) { |
282 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); | 298 x509_util::GetPublicKeyInfo(cert_handle, size_bits, type); |
283 } | 299 } |
284 | 300 |
285 } // namespace net | 301 } // namespace net |
OLD | NEW |