Index: net/test/spawned_test_server/base_test_server.cc |
diff --git a/net/test/spawned_test_server/base_test_server.cc b/net/test/spawned_test_server/base_test_server.cc |
index bff9babefac4fd19b3fa9ac547088f1a6fbdd817..f6c09c0e91a0c7590134622d96c00c213686c2a6 100644 |
--- a/net/test/spawned_test_server/base_test_server.cc |
+++ b/net/test/spawned_test_server/base_test_server.cc |
@@ -19,6 +19,7 @@ |
#include "net/base/port_util.h" |
#include "net/base/test_completion_callback.h" |
#include "net/cert/test_root_certs.h" |
+#include "net/cert/x509_certificate.h" |
#include "net/dns/host_resolver.h" |
#include "net/log/net_log.h" |
#include "url/gurl.h" |
@@ -335,6 +336,25 @@ bool BaseTestServer::LoadTestRootCert() const { |
root_certificate_path.AppendASCII("root_ca_cert.pem")); |
} |
+scoped_refptr<X509Certificate> BaseTestServer::GetCertificate() const { |
+ base::FilePath certificate_path(certificates_dir_); |
davidben
2015/08/07 14:50:28
Huh. Apparently certificates_dir_ is kind of wonky
estark
2015/08/07 18:19:14
Ah, so you mean that GetLocalCertificatesDir() sho
|
+ base::FilePath certificate_file(ssl_options_.GetCertificateFile()); |
+ if (certificate_file.value().empty()) |
+ return nullptr; |
+ certificate_path = certificate_path.Append(certificate_file); |
+ |
+ std::string cert_data; |
+ if (!base::ReadFileToString(certificate_path, &cert_data)) |
+ return nullptr; |
+ |
+ CertificateList certs_in_file = |
+ X509Certificate::CreateCertificateListFromBytes( |
+ cert_data.data(), cert_data.size(), X509Certificate::FORMAT_AUTO); |
davidben
2015/08/07 14:50:28
Since the test server itself only accepts PEM, I t
estark
2015/08/07 18:19:14
Done.
|
+ if (certs_in_file.empty()) |
+ return nullptr; |
+ return certs_in_file[0]; |
+} |
+ |
void BaseTestServer::Init(const std::string& host) { |
host_port_pair_ = HostPortPair(host, 0); |