Chromium Code Reviews| Index: chrome/browser/io_thread.cc |
| diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
| index 952964b1b79a7b16d32de582d06b4334a6b7086f..d99e4a074d8b7efc4c6e34835320124b73f9cdcd 100644 |
| --- a/chrome/browser/io_thread.cc |
| +++ b/chrome/browser/io_thread.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/command_line.h" |
| #include "base/compiler_specific.h" |
| #include "base/debug/leak_tracker.h" |
| +#include "base/environment.h" |
| #include "base/logging.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/prefs/pref_registry_simple.h" |
| @@ -80,6 +81,7 @@ |
| #include "net/quic/crypto/crypto_protocol.h" |
| #include "net/quic/quic_protocol.h" |
| #include "net/quic/quic_utils.h" |
| +#include "net/socket/ssl_client_socket.h" |
| #include "net/socket/tcp_client_socket.h" |
| #include "net/spdy/spdy_session.h" |
| #include "net/ssl/channel_id_service.h" |
| @@ -159,6 +161,25 @@ void ObserveKeychainEvents() { |
| } |
| #endif |
| +// Gets file path into ssl_keylog_file from command line argument or |
| +// environment variable. Command line argument has priority when |
| +// both specified. |
| +std::string GetSSLKeyLogFile(const base::CommandLine& command_line){ |
| + std::string ssl_keylog_file; |
| + if (command_line.HasSwitch(switches::kSSLKeyLogFile)) { |
| + ssl_keylog_file = command_line.GetSwitchValueASCII( |
| + switches::kSSLKeyLogFile); |
| + if (!ssl_keylog_file.empty()) { |
| + return ssl_keylog_file; |
| + } else { |
| + LOG(WARNING) << "ssl-key-log-file argument missing"; |
| + } |
| + } |
| + scoped_ptr<base::Environment> env(base::Environment::Create()); |
| + env->GetVar("SSLKEYLOGFILE", &ssl_keylog_file); |
| + return ssl_keylog_file; |
| +} |
|
Ryan Hamilton
2015/10/16 02:37:30
Nit: I would format this slightly differently. (In
Zhongyi Shi
2015/10/16 17:36:03
Done.
|
| + |
| // Used for the "system" URLRequestContext. |
| class SystemURLRequestContext : public net::URLRequestContext { |
| public: |
| @@ -553,6 +574,12 @@ void IOThread::Init() { |
| const base::CommandLine& command_line = |
| *base::CommandLine::ForCurrentProcess(); |
| + // Export ssl keys if log file specified. |
| + std::string ssl_keylog_file = GetSSLKeyLogFile(command_line); |
| + if (!ssl_keylog_file.empty()) { |
| + net::SSLClientSocket::SetSSLKeyLogFile(ssl_keylog_file); |
| + } |
| + |
| DCHECK(!globals_); |
| globals_ = new Globals; |