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 #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 #include <time.h> | 10 #include <time.h> |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 encCert->CertEncoding, &certificate_ref); | 681 encCert->CertEncoding, &certificate_ref); |
682 if (os_status != 0) { | 682 if (os_status != 0) { |
683 DLOG(ERROR) << "SecCertificateCreateFromData failed: " << os_status; | 683 DLOG(ERROR) << "SecCertificateCreateFromData failed: " << os_status; |
684 return NULL; | 684 return NULL; |
685 } | 685 } |
686 scoped_cert.reset(certificate_ref); | 686 scoped_cert.reset(certificate_ref); |
687 | 687 |
688 return CreateFromHandle(scoped_cert, X509Certificate::OSCertHandles()); | 688 return CreateFromHandle(scoped_cert, X509Certificate::OSCertHandles()); |
689 } | 689 } |
690 | 690 |
| 691 // static |
| 692 X509Certificate* X509Certificate::CreateOriginBound( |
| 693 crypto::RSAPrivateKey* key, |
| 694 const std::string& origin, |
| 695 uint32 serial_number, |
| 696 base::TimeDelta valid_duration) { |
| 697 // TODO(wtc): this cannot be implemented by creating a CE_DataAndType for |
| 698 // the origin-bound extension and adding it to certReq.extensions because |
| 699 // it is not one of the supported extensions in the CE_DataType enum type. |
| 700 // Using the DT_Other enum constant does not work. |
| 701 // |
| 702 // The relevant Apple headers are: |
| 703 // - CSSM_APPLE_TP_CERT_REQUEST is defined in cssmapple.h. |
| 704 // - CE_DataAndType, CE_DataType, and CE_Data are defined in |
| 705 // certextensions.h. |
| 706 NOTIMPLEMENTED(); |
| 707 return NULL; |
| 708 } |
| 709 |
691 void X509Certificate::GetSubjectAltName( | 710 void X509Certificate::GetSubjectAltName( |
692 std::vector<std::string>* dns_names, | 711 std::vector<std::string>* dns_names, |
693 std::vector<std::string>* ip_addrs) const { | 712 std::vector<std::string>* ip_addrs) const { |
694 if (dns_names) | 713 if (dns_names) |
695 dns_names->clear(); | 714 dns_names->clear(); |
696 if (ip_addrs) | 715 if (ip_addrs) |
697 ip_addrs->clear(); | 716 ip_addrs->clear(); |
698 | 717 |
699 CSSMFields fields; | 718 CSSMFields fields; |
700 OSStatus status = GetCertFields(cert_handle_, &fields); | 719 OSStatus status = GetCertFields(cert_handle_, &fields); |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 CSSM_DATA cert_data; | 1349 CSSM_DATA cert_data; |
1331 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); | 1350 OSStatus status = SecCertificateGetData(cert_handle, &cert_data); |
1332 if (status) | 1351 if (status) |
1333 return false; | 1352 return false; |
1334 | 1353 |
1335 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), | 1354 return pickle->WriteData(reinterpret_cast<char*>(cert_data.Data), |
1336 cert_data.Length); | 1355 cert_data.Length); |
1337 } | 1356 } |
1338 | 1357 |
1339 } // namespace net | 1358 } // namespace net |
OLD | NEW |