diff options
author | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 13:30:36 +0000 |
---|---|---|
committer | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 13:30:36 +0000 |
commit | 38e2860572389123e81ab7b87d6b6e0a7328e700 (patch) | |
tree | 7f8ca2dec7d6059381ceb12aef6490926e928775 /net/cert | |
parent | 4caf7f86c0e9e26b0a3d3b56dc46c3944379d410 (diff) | |
download | chromium_src-38e2860572389123e81ab7b87d6b6e0a7328e700.zip chromium_src-38e2860572389123e81ab7b87d6b6e0a7328e700.tar.gz chromium_src-38e2860572389123e81ab7b87d6b6e0a7328e700.tar.bz2 |
Refactor certificate reference resolving in ONC.
In ONC certificates are referenced by GUIDs. The resolve code replaces these by the certs' PEM encoding.
After this change the resolve function is
- separated from the actual certificate import.
- doesn't require the creation of any X509Certificate.
BUG=208986
R=eroman@chromium.org, rsleevi@chromium.org, stevenjb@chromium.org
Review URL: https://codereview.chromium.org/18190005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/cert')
-rw-r--r-- | net/cert/x509_certificate.cc | 16 | ||||
-rw-r--r-- | net/cert/x509_certificate.h | 6 |
2 files changed, 18 insertions, 4 deletions
diff --git a/net/cert/x509_certificate.cc b/net/cert/x509_certificate.cc index 97b00c3..36e806e 100644 --- a/net/cert/x509_certificate.cc +++ b/net/cert/x509_certificate.cc @@ -656,10 +656,9 @@ bool X509Certificate::VerifyNameMatch(const std::string& hostname) const { } // static -bool X509Certificate::GetPEMEncoded(OSCertHandle cert_handle, - std::string* pem_encoded) { - std::string der_encoded; - if (!GetDEREncoded(cert_handle, &der_encoded) || der_encoded.empty()) +bool X509Certificate::GetPEMEncodedFromDER(const std::string& der_encoded, + std::string* pem_encoded) { + if (der_encoded.empty()) return false; std::string b64_encoded; if (!base::Base64Encode(der_encoded, &b64_encoded) || b64_encoded.empty()) @@ -679,6 +678,15 @@ bool X509Certificate::GetPEMEncoded(OSCertHandle cert_handle, return true; } +// static +bool X509Certificate::GetPEMEncoded(OSCertHandle cert_handle, + std::string* pem_encoded) { + std::string der_encoded; + if (!GetDEREncoded(cert_handle, &der_encoded)) + return false; + return GetPEMEncodedFromDER(der_encoded, pem_encoded); +} + bool X509Certificate::GetPEMEncodedChain( std::vector<std::string>* pem_encoded) const { std::vector<std::string> encoded_chain; diff --git a/net/cert/x509_certificate.h b/net/cert/x509_certificate.h index 28961ee..ef55243 100644 --- a/net/cert/x509_certificate.h +++ b/net/cert/x509_certificate.h @@ -321,6 +321,12 @@ class NET_EXPORT X509Certificate static bool GetDEREncoded(OSCertHandle cert_handle, std::string* der_encoded); + // Returns the PEM encoded data from a DER encoded certificate. If the return + // value is true, then the PEM encoded certificate is written to + // |pem_encoded|. + static bool GetPEMEncodedFromDER(const std::string& der_encoded, + std::string* pem_encoded); + // Returns the PEM encoded data from an OSCertHandle. If the return value is // true, then the PEM encoded certificate is written to |pem_encoded|. static bool GetPEMEncoded(OSCertHandle cert_handle, |