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

Side by Side Diff: remoting/protocol/ssl_hmac_channel_authenticator.cc

Issue 1518613002: Support for server session cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_certs
Patch Set: Rebased to head Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 scoped_ptr<SslHmacChannelAuthenticator> 184 scoped_ptr<SslHmacChannelAuthenticator>
185 SslHmacChannelAuthenticator::CreateForHost( 185 SslHmacChannelAuthenticator::CreateForHost(
186 const std::string& local_cert, 186 const std::string& local_cert,
187 scoped_refptr<RsaKeyPair> key_pair, 187 scoped_refptr<RsaKeyPair> key_pair,
188 const std::string& auth_key) { 188 const std::string& auth_key) {
189 scoped_ptr<SslHmacChannelAuthenticator> result( 189 scoped_ptr<SslHmacChannelAuthenticator> result(
190 new SslHmacChannelAuthenticator(auth_key)); 190 new SslHmacChannelAuthenticator(auth_key));
191 result->local_cert_ = local_cert; 191 result->local_cert_ = local_cert;
192 result->local_key_pair_ = key_pair; 192 result->local_key_pair_ = key_pair;
193 result->InitializeSSLServerContext();
193 return result; 194 return result;
194 } 195 }
195 196
196 SslHmacChannelAuthenticator::SslHmacChannelAuthenticator( 197 SslHmacChannelAuthenticator::SslHmacChannelAuthenticator(
197 const std::string& auth_key) 198 const std::string& auth_key)
198 : auth_key_(auth_key) { 199 : auth_key_(auth_key) {
199 } 200 }
200 201
201 SslHmacChannelAuthenticator::~SslHmacChannelAuthenticator() { 202 SslHmacChannelAuthenticator::~SslHmacChannelAuthenticator() {
202 } 203 }
203 204
204 void SslHmacChannelAuthenticator::SecureAndAuthenticate( 205 void SslHmacChannelAuthenticator::InitializeSSLServerContext() {
205 scoped_ptr<P2PStreamSocket> socket,
206 const DoneCallback& done_callback) {
207 DCHECK(CalledOnValidThread());
208
209 done_callback_ = done_callback;
210
211 int result;
212 if (is_ssl_server()) { 206 if (is_ssl_server()) {
213 #if defined(OS_NACL) 207 #if defined(OS_NACL)
214 // Client plugin doesn't use server SSL sockets, and so SSLServerSocket 208 // Client plugin doesn't use server SSL sockets, and so SSLServerSocket
215 // implementation is not compiled for NaCl as part of net_nacl. 209 // implementation is not compiled for NaCl as part of net_nacl.
216 NOTREACHED(); 210 NOTREACHED();
217 result = net::ERR_FAILED;
218 #else 211 #else
219 scoped_refptr<net::X509Certificate> cert = 212 scoped_refptr<net::X509Certificate> cert =
220 net::X509Certificate::CreateFromBytes( 213 net::X509Certificate::CreateFromBytes(
221 local_cert_.data(), local_cert_.length()); 214 local_cert_.data(), local_cert_.length());
222 if (!cert.get()) { 215 if (!cert.get()) {
223 LOG(ERROR) << "Failed to parse X509Certificate"; 216 LOG(ERROR) << "Failed to parse X509Certificate";
224 NotifyError(net::ERR_FAILED); 217 NotifyError(net::ERR_FAILED);
225 return; 218 return;
226 } 219 }
227 220
228 net::SSLServerConfig ssl_config; 221 net::SSLServerConfig ssl_config;
229 ssl_config.require_ecdhe = true; 222 ssl_config.require_ecdhe = true;
230 223
231 scoped_ptr<net::SSLServerSocket> server_socket = net::CreateSSLServerSocket( 224 server_context_ = net::CreateSSLServerContext(
232 make_scoped_ptr(new NetStreamSocketAdapter(std::move(socket))),
233 cert.get(), *local_key_pair_->private_key(), ssl_config); 225 cert.get(), *local_key_pair_->private_key(), ssl_config);
226 #endif
227 }
228 }
229
230 void SslHmacChannelAuthenticator::SecureAndAuthenticate(
davidben 2016/02/24 21:01:26 It looks like this only gets called once[*] for ea
ryanchung 2016/02/25 00:46:39 Done.
231 scoped_ptr<P2PStreamSocket> socket,
232 const DoneCallback& done_callback) {
233 DCHECK(CalledOnValidThread());
234
235 done_callback_ = done_callback;
236
237 int result;
238 if (is_ssl_server()) {
239 #if defined(OS_NACL)
240 // Client plugin doesn't use server SSL sockets, and so SSLServerSocket
241 // implementation is not compiled for NaCl as part of net_nacl.
242 NOTREACHED();
243 result = net::ERR_FAILED;
244 #else
245 scoped_ptr<net::SSLServerSocket> server_socket =
246 server_context_->CreateSSLServerSocket(
247 make_scoped_ptr(new NetStreamSocketAdapter(std::move(socket))));
234 net::SSLServerSocket* raw_server_socket = server_socket.get(); 248 net::SSLServerSocket* raw_server_socket = server_socket.get();
235 socket_ = std::move(server_socket); 249 socket_ = std::move(server_socket);
236 result = raw_server_socket->Handshake( 250 result = raw_server_socket->Handshake(
237 base::Bind(&SslHmacChannelAuthenticator::OnConnected, 251 base::Bind(&SslHmacChannelAuthenticator::OnConnected,
238 base::Unretained(this))); 252 base::Unretained(this)));
239 #endif 253 #endif
240 } else { 254 } else {
241 transport_security_state_.reset(new net::TransportSecurityState); 255 transport_security_state_.reset(new net::TransportSecurityState);
242 cert_verifier_.reset(new FailingCertVerifier); 256 cert_verifier_.reset(new FailingCertVerifier);
243 257
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 make_scoped_ptr(new P2PStreamSocketAdapter(std::move(socket_)))); 448 make_scoped_ptr(new P2PStreamSocketAdapter(std::move(socket_))));
435 } 449 }
436 } 450 }
437 451
438 void SslHmacChannelAuthenticator::NotifyError(int error) { 452 void SslHmacChannelAuthenticator::NotifyError(int error) {
439 base::ResetAndReturn(&done_callback_).Run(error, nullptr); 453 base::ResetAndReturn(&done_callback_).Run(error, nullptr);
440 } 454 }
441 455
442 } // namespace protocol 456 } // namespace protocol
443 } // namespace remoting 457 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698