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 <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> |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 // Sign the ASN1 encoded cert and save it to |result|. | 743 // Sign the ASN1 encoded cert and save it to |result|. |
744 rv = SEC_DerSignData(arena, result, der.data, der.len, key->key(), algo_id); | 744 rv = SEC_DerSignData(arena, result, der.data, der.len, key->key(), algo_id); |
745 if (rv != SECSuccess) { | 745 if (rv != SECSuccess) { |
746 CERT_DestroyCertificate(cert); | 746 CERT_DestroyCertificate(cert); |
747 return NULL; | 747 return NULL; |
748 } | 748 } |
749 | 749 |
750 // Save the signed result to the cert. | 750 // Save the signed result to the cert. |
751 cert->derCert = *result; | 751 cert->derCert = *result; |
752 | 752 |
753 X509Certificate* x509_cert = | 753 X509Certificate* x509_cert = CreateFromHandle(cert, OSCertHandles()); |
754 CreateFromHandle(cert, SOURCE_LONE_CERT_IMPORT, OSCertHandles()); | |
755 CERT_DestroyCertificate(cert); | 754 CERT_DestroyCertificate(cert); |
756 return x509_cert; | 755 return x509_cert; |
757 } | 756 } |
758 | 757 |
759 void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const { | 758 void X509Certificate::GetDNSNames(std::vector<std::string>* dns_names) const { |
760 dns_names->clear(); | 759 dns_names->clear(); |
761 | 760 |
762 // Compare with CERT_VerifyCertName(). | 761 // Compare with CERT_VerifyCertName(). |
763 GetCertSubjectAltNamesOfType(cert_handle_, certDNSName, dns_names); | 762 GetCertSubjectAltNamesOfType(cert_handle_, certDNSName, dns_names); |
764 | 763 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1003 |
1005 // static | 1004 // static |
1006 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 1005 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
1007 Pickle* pickle) { | 1006 Pickle* pickle) { |
1008 return pickle->WriteData( | 1007 return pickle->WriteData( |
1009 reinterpret_cast<const char*>(cert_handle->derCert.data), | 1008 reinterpret_cast<const char*>(cert_handle->derCert.data), |
1010 cert_handle->derCert.len); | 1009 cert_handle->derCert.len); |
1011 } | 1010 } |
1012 | 1011 |
1013 } // namespace net | 1012 } // namespace net |
OLD | NEW |