Skip to content

Commit

Permalink
Gives crashpad an option to use TLS 1.1 and 1.2 on Windows 7 and 8.0
Browse files Browse the repository at this point in the history
in addition to TLS 1.0 used by WinHttp by default.

Fixes brave/brave-browser#1188
  • Loading branch information
mkarolin committed Jan 11, 2019
1 parent 8edd59a commit d0be988
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <windows.h>
#include <versionhelpers.h>
#include <winhttp.h>

#include "base/logging.h"

// Forward declaration.
namespace crashpad {
namespace {
std::string WinHttpMessage(const char* extra);
}
}

namespace {

void BraveSetSessionOptions(HINTERNET hSession) {
// Windows 8.1+ already have TLS 1.1 and 1.2 available by default.
if (IsWindows8Point1OrGreater())
return;

// Use TLS 1.0, 1.1, or 1.2.
unsigned long secure_protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2;

// Set protocols and log an error if we can't. Bailing out on the session due
// to an error here is not necessary since if TLS 1.1 or 1.2 is required to
// connect then the connection will fail anyway.
if (!WinHttpSetOption(hSession, WINHTTP_OPTION_SECURE_PROTOCOLS,
&secure_protocols, sizeof(secure_protocols))) {
LOG(ERROR) << crashpad::WinHttpMessage("WinHttpSetOption");
}
}

} // namespace

// The original file is patched to call the above function.
#include "../../../../../../../third_party/crashpad/crashpad/util/net/http_transport_win.cc"

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_win.cc b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
index 2919bc11d0ba4bf84a11e146bf2961b830db35fe..56811eb3e2879e76404c836e6791f8c0ed317595 100644
--- a/third_party/crashpad/crashpad/util/net/http_transport_win.cc
+++ b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
@@ -153,6 +153,8 @@ bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
return false;
}

+ BraveSetSessionOptions(session.get());
+
int timeout_in_ms = static_cast<int>(timeout() * 1000);
if (!WinHttpSetTimeouts(session.get(),
timeout_in_ms,

0 comments on commit d0be988

Please sign in to comment.