Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: net/socket/ssl_server_socket_openssl.cc

Issue 329143002: Compile fix for OpenSSL on Mac and Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final nit fixes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_server_socket_openssl.cc
diff --git a/net/socket/ssl_server_socket_openssl.cc b/net/socket/ssl_server_socket_openssl.cc
index 556f87d33e3298703eb01aebad33aa365bca8c08..f6bd0cd8f819198c31d6eabcf677d5508b71b4be 100644
--- a/net/socket/ssl_server_socket_openssl.cc
+++ b/net/socket/ssl_server_socket_openssl.cc
@@ -616,10 +616,31 @@ int SSLServerSocketOpenSSL::Init() {
// Set certificate and private key.
DCHECK(cert_->os_cert_handle());
+#if defined(USE_OPENSSL_CERTS)
if (SSL_use_certificate(ssl_, cert_->os_cert_handle()) != 1) {
LOG(ERROR) << "Cannot set certificate.";
return ERR_UNEXPECTED;
}
+#else
+ // Convert OSCertHandle to X509 structure.
+ std::string der_string;
+ if (!X509Certificate::GetDEREncoded(cert_->os_cert_handle(), &der_string))
+ return ERR_UNEXPECTED;
+
+ const unsigned char* der_string_array =
+ reinterpret_cast<const unsigned char*>(der_string.data());
+
+ crypto::ScopedOpenSSL<X509, X509_free>
+ x509(d2i_X509(NULL, &der_string_array, der_string.length()));
+ if (!x509.get())
+ return ERR_UNEXPECTED;
+
+ // On success, SSL_use_certificate acquires a reference to |x509|.
+ if (SSL_use_certificate(ssl_, x509.get()) != 1) {
+ LOG(ERROR) << "Cannot set certificate.";
+ return ERR_UNEXPECTED;
+ }
+#endif // USE_OPENSSL_CERTS
DCHECK(key_->key());
if (SSL_use_PrivateKey(ssl_, key_->key()) != 1) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698