summaryrefslogtreecommitdiffstats
path: root/net/cert
diff options
context:
space:
mode:
Diffstat (limited to 'net/cert')
-rw-r--r--net/cert/x509_certificate.cc16
-rw-r--r--net/cert/x509_certificate.h6
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,