Index: net/socket/ssl_client_socket_openssl.cc |
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc |
index 1e0d799e6a731167e86489a9449142eb78752a91..23ea8cb8a49cb9ea5c2c2d52a9ed262251142b74 100644 |
--- a/net/socket/ssl_client_socket_openssl.cc |
+++ b/net/socket/ssl_client_socket_openssl.cc |
@@ -222,6 +222,18 @@ class SSLClientSocketOpenSSL::SSLContext { |
private: |
friend struct base::DefaultSingletonTraits<SSLContext>; |
+ void SetKeyLogFile(std::string ssl_keylog_file) { |
+ DCHECK(!ssl_keylog_file.empty()); |
+ crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
+ BIO* bio = BIO_new_file(ssl_keylog_file.c_str(), "a"); |
+ if (!bio) { |
+ LOG(ERROR) << "Failed to open " << ssl_keylog_file; |
+ ERR_print_errors_cb(&LogErrorCallback, NULL); |
+ } else { |
+ SSL_CTX_set_keylog_bio(ssl_ctx_.get(), bio); |
+ } |
+ } |
+ |
SSLContext() : session_cache_(SSLClientSessionCacheOpenSSL::Config()) { |
crypto::EnsureOpenSSLInit(); |
ssl_socket_data_index_ = SSL_get_ex_new_index(0, 0, 0, 0, 0); |
@@ -250,14 +262,7 @@ class SSLClientSocketOpenSSL::SSLContext { |
std::string ssl_keylog_file; |
if (env->GetVar("SSLKEYLOGFILE", &ssl_keylog_file) && |
!ssl_keylog_file.empty()) { |
- crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
- BIO* bio = BIO_new_file(ssl_keylog_file.c_str(), "a"); |
- if (!bio) { |
- LOG(ERROR) << "Failed to open " << ssl_keylog_file; |
- ERR_print_errors_cb(&LogErrorCallback, NULL); |
- } else { |
- SSL_CTX_set_keylog_bio(ssl_ctx_.get(), bio); |
- } |
+ SetKeyLogFile(ssl_keylog_file); |
} |
} |