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 <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
10 | 10 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // is properly decoded as a PKCS#7, whether PEM or not, which avoids | 189 // is properly decoded as a PKCS#7, whether PEM or not, which avoids |
190 // the need to fallback to internal decoding. | 190 // the need to fallback to internal decoding. |
191 if (IsValidOSCertHandle(cert)) { | 191 if (IsValidOSCertHandle(cert)) { |
192 CFRetain(cert); | 192 CFRetain(cert); |
193 output->push_back(cert); | 193 output->push_back(cert); |
194 } | 194 } |
195 } | 195 } |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
199 struct CSSMOIDString { | |
200 const CSSM_OID* oid_; | |
201 std::string string_; | |
202 }; | |
203 | |
204 typedef std::vector<CSSMOIDString> CSSMOIDStringVector; | |
205 | |
206 class ScopedEncodedCertResults { | |
207 public: | |
208 explicit ScopedEncodedCertResults(CSSM_TP_RESULT_SET* results) | |
209 : results_(results) { } | |
210 ~ScopedEncodedCertResults() { | |
211 if (results_) { | |
212 CSSM_ENCODED_CERT* encCert = | |
213 reinterpret_cast<CSSM_ENCODED_CERT*>(results_->Results); | |
214 for (uint32 i = 0; i < results_->NumberOfResults; i++) { | |
215 crypto::CSSMFree(encCert[i].CertBlob.Data); | |
216 } | |
217 crypto::CSSMFree(results_->Results); | |
218 crypto::CSSMFree(results_); | |
219 } | |
220 } | |
221 | |
222 private: | |
223 CSSM_TP_RESULT_SET* results_; | |
224 }; | |
225 | |
226 } // namespace | 199 } // namespace |
227 | 200 |
228 void X509Certificate::Initialize() { | 201 void X509Certificate::Initialize() { |
229 x509_util::CSSMCachedCertificate cached_cert; | 202 x509_util::CSSMCachedCertificate cached_cert; |
230 if (cached_cert.Init(cert_handle_) == CSSM_OK) { | 203 if (cached_cert.Init(cert_handle_) == CSSM_OK) { |
231 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1SubjectNameStd, | 204 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1SubjectNameStd, |
232 &subject_); | 205 &subject_); |
233 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1IssuerNameStd, | 206 GetCertDistinguishedName(cached_cert, &CSSMOID_X509V1IssuerNameStd, |
234 &issuer_); | 207 &issuer_); |
235 GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotBefore, | 208 GetCertDateForOID(cached_cert, &CSSMOID_X509V1ValidityNotBefore, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 *type = kPublicKeyTypeDH; | 506 *type = kPublicKeyTypeDH; |
534 break; | 507 break; |
535 default: | 508 default: |
536 *type = kPublicKeyTypeUnknown; | 509 *type = kPublicKeyTypeUnknown; |
537 *size_bits = 0; | 510 *size_bits = 0; |
538 break; | 511 break; |
539 } | 512 } |
540 } | 513 } |
541 | 514 |
542 } // namespace net | 515 } // namespace net |
OLD | NEW |