summaryrefslogtreecommitdiffstats
path: root/net/base/origin_bound_cert_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/origin_bound_cert_service.cc')
-rw-r--r--net/base/origin_bound_cert_service.cc22
1 files changed, 5 insertions, 17 deletions
diff --git a/net/base/origin_bound_cert_service.cc b/net/base/origin_bound_cert_service.cc
index 4b48e61..e5c1e9d 100644
--- a/net/base/origin_bound_cert_service.cc
+++ b/net/base/origin_bound_cert_service.cc
@@ -19,6 +19,7 @@
#include "net/base/net_errors.h"
#include "net/base/origin_bound_cert_store.h"
#include "net/base/x509_certificate.h"
+#include "net/base/x509_util.h"
#if defined(USE_NSS)
#include <private/pprthred.h> // PR_DetachThread
@@ -324,20 +325,13 @@ int OriginBoundCertService::GenerateCert(const std::string& origin,
LOG(WARNING) << "Unable to create key pair for client";
return ERR_KEY_GENERATION_FAILED;
}
-#if defined(USE_NSS)
- scoped_refptr<X509Certificate> x509_cert = X509Certificate::CreateOriginBound(
+ std::string der_cert;
+ if (!x509_util::CreateOriginBoundCert(
key.get(),
origin,
serial_number,
- base::TimeDelta::FromDays(kValidityPeriodInDays));
-#else
- scoped_refptr<X509Certificate> x509_cert = X509Certificate::CreateSelfSigned(
- key.get(),
- "CN=anonymous.invalid",
- serial_number,
- base::TimeDelta::FromDays(kValidityPeriodInDays));
-#endif
- if (!x509_cert) {
+ base::TimeDelta::FromDays(kValidityPeriodInDays),
+ &der_cert)) {
LOG(WARNING) << "Unable to create x509 cert for client";
return ERR_ORIGIN_BOUND_CERT_GENERATION_FAILED;
}
@@ -351,12 +345,6 @@ int OriginBoundCertService::GenerateCert(const std::string& origin,
// std::string* to prevent this copying.
std::string key_out(private_key_info.begin(), private_key_info.end());
- std::string der_cert;
- if (!x509_cert->GetDEREncoded(&der_cert)) {
- LOG(WARNING) << "Unable to get DER-encoded cert";
- return ERR_GET_CERT_BYTES_FAILED;
- }
-
private_key->swap(key_out);
cert->swap(der_cert);
return OK;