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

Unified Diff: net/http/http_stream_parser.cc

Issue 1378613004: Set Token-Binding HTTP header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tb-tls-ext-new
Patch Set: rebase Created 5 years, 3 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
Index: net/http/http_stream_parser.cc
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 9ddae4853dacb370c5072a34ddcdea90f8a52404..1d62f95c4d7c3945f949f2dad0148bb0262a345e 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -4,6 +4,7 @@
#include "net/http/http_stream_parser.h"
+#include "base/base64.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
@@ -22,6 +23,7 @@
#include "net/http/http_util.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/ssl_client_socket.h"
+#include "net/ssl/token_binding.h"
namespace net {
@@ -1098,6 +1100,38 @@ void HttpStreamParser::GetSSLCertRequestInfo(
}
}
+int HttpStreamParser::GetTokenBindingMessageHeader(std::string* out) {
+ if (!request_->url.SchemeIsCryptographic() || !connection_->socket()) {
+ *out = "";
+ return OK;
+ }
+ SSLClientSocket* ssl_socket =
+ static_cast<SSLClientSocket*>(connection_->socket());
+ SSLInfo ssl_info;
+ if (!ssl_socket->GetSSLInfo(&ssl_info) ||
+ !ssl_info.token_binding_negotiated) {
+ *out = "";
+ return OK;
+ }
+ std::string provided_token_binding = ssl_socket->GetProvidedTokenBinding();
+ if (provided_token_binding == "") {
+ *out = "";
+ return OK;
+ }
+ std::string token_binding_message;
+ std::vector<std::string> token_bindings;
+ token_bindings.push_back(provided_token_binding);
+ int rv;
+ if ((rv = BuildTokenBindingMessageFromTokenBindings(
+ token_bindings, &token_binding_message)) != OK) {
+ return rv;
+ }
+ base::Base64Encode(token_binding_message, out);
+ base::ReplaceChars(*out, "+", "-", out);
+ base::ReplaceChars(*out, "/", "_", out);
+ return OK;
+}
+
int HttpStreamParser::EncodeChunk(const base::StringPiece& payload,
char* output,
size_t output_size) {

Powered by Google App Engine
This is Rietveld 408576698