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) { |