| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" | 5 #include "extensions/browser/api/cast_channel/cast_socket.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "extensions/browser/api/cast_channel/cast_message_util.h" | 27 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
| 28 #include "extensions/browser/api/cast_channel/cast_transport.h" | 28 #include "extensions/browser/api/cast_channel/cast_transport.h" |
| 29 #include "extensions/browser/api/cast_channel/logger.h" | 29 #include "extensions/browser/api/cast_channel/logger.h" |
| 30 #include "extensions/browser/api/cast_channel/logger_util.h" | 30 #include "extensions/browser/api/cast_channel/logger_util.h" |
| 31 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 31 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
| 32 #include "net/base/address_list.h" | 32 #include "net/base/address_list.h" |
| 33 #include "net/base/host_port_pair.h" | 33 #include "net/base/host_port_pair.h" |
| 34 #include "net/base/net_errors.h" | 34 #include "net/base/net_errors.h" |
| 35 #include "net/cert/cert_verifier.h" | 35 #include "net/cert/cert_verifier.h" |
| 36 #include "net/cert/cert_verify_result.h" | 36 #include "net/cert/cert_verify_result.h" |
| 37 #include "net/cert/ct_policy_enforcer.h" |
| 38 #include "net/cert/multi_log_ct_verifier.h" |
| 37 #include "net/cert/x509_certificate.h" | 39 #include "net/cert/x509_certificate.h" |
| 38 #include "net/http/transport_security_state.h" | 40 #include "net/http/transport_security_state.h" |
| 39 #include "net/socket/client_socket_factory.h" | 41 #include "net/socket/client_socket_factory.h" |
| 40 #include "net/socket/client_socket_handle.h" | 42 #include "net/socket/client_socket_handle.h" |
| 41 #include "net/socket/ssl_client_socket.h" | 43 #include "net/socket/ssl_client_socket.h" |
| 42 #include "net/socket/stream_socket.h" | 44 #include "net/socket/stream_socket.h" |
| 43 #include "net/socket/tcp_client_socket.h" | 45 #include "net/socket/tcp_client_socket.h" |
| 44 #include "net/ssl/ssl_config_service.h" | 46 #include "net/ssl/ssl_config_service.h" |
| 45 #include "net/ssl/ssl_info.h" | 47 #include "net/ssl/ssl_info.h" |
| 46 | 48 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // Options cannot be set on the TCPClientSocket yet, because the | 181 // Options cannot be set on the TCPClientSocket yet, because the |
| 180 // underlying platform socket will not be created until Bind() | 182 // underlying platform socket will not be created until Bind() |
| 181 // or Connect() is called. | 183 // or Connect() is called. |
| 182 } | 184 } |
| 183 | 185 |
| 184 std::unique_ptr<net::SSLClientSocket> CastSocketImpl::CreateSslSocket( | 186 std::unique_ptr<net::SSLClientSocket> CastSocketImpl::CreateSslSocket( |
| 185 std::unique_ptr<net::StreamSocket> socket) { | 187 std::unique_ptr<net::StreamSocket> socket) { |
| 186 net::SSLConfig ssl_config; | 188 net::SSLConfig ssl_config; |
| 187 cert_verifier_ = base::WrapUnique(new FakeCertVerifier); | 189 cert_verifier_ = base::WrapUnique(new FakeCertVerifier); |
| 188 transport_security_state_.reset(new net::TransportSecurityState); | 190 transport_security_state_.reset(new net::TransportSecurityState); |
| 191 cert_transparency_verifier_.reset(new net::MultiLogCTVerifier()); |
| 192 ct_policy_enforcer_.reset(new net::CTPolicyEnforcer()); |
| 193 |
| 194 // Note that |context| fields remain owned by CastSocketImpl. |
| 189 net::SSLClientSocketContext context; | 195 net::SSLClientSocketContext context; |
| 190 // CertVerifier and TransportSecurityState are owned by us, not the | |
| 191 // context object. | |
| 192 context.cert_verifier = cert_verifier_.get(); | 196 context.cert_verifier = cert_verifier_.get(); |
| 193 context.transport_security_state = transport_security_state_.get(); | 197 context.transport_security_state = transport_security_state_.get(); |
| 198 context.cert_transparency_verifier = cert_transparency_verifier_.get(); |
| 199 context.ct_policy_enforcer = ct_policy_enforcer_.get(); |
| 194 | 200 |
| 195 std::unique_ptr<net::ClientSocketHandle> connection( | 201 std::unique_ptr<net::ClientSocketHandle> connection( |
| 196 new net::ClientSocketHandle); | 202 new net::ClientSocketHandle); |
| 197 connection->SetSocket(std::move(socket)); | 203 connection->SetSocket(std::move(socket)); |
| 198 net::HostPortPair host_and_port = net::HostPortPair::FromIPEndPoint( | 204 net::HostPortPair host_and_port = net::HostPortPair::FromIPEndPoint( |
| 199 ip_endpoint_); | 205 ip_endpoint_); |
| 200 | 206 |
| 201 return net::ClientSocketFactory::GetDefaultFactory()->CreateSSLClientSocket( | 207 return net::ClientSocketFactory::GetDefaultFactory()->CreateSSLClientSocket( |
| 202 std::move(connection), host_and_port, ssl_config, context); | 208 std::move(connection), host_and_port, ssl_config, context); |
| 203 } | 209 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; | 621 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; |
| 616 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); | 622 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); |
| 617 error_state_ = error_state; | 623 error_state_ = error_state; |
| 618 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_)); | 624 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_)); |
| 619 delegate_->OnError(error_state_); | 625 delegate_->OnError(error_state_); |
| 620 } | 626 } |
| 621 } // namespace cast_channel | 627 } // namespace cast_channel |
| 622 } // namespace api | 628 } // namespace api |
| 623 } // namespace extensions | 629 } // namespace extensions |
| 624 #undef VLOG_WITH_CONNECTION | 630 #undef VLOG_WITH_CONNECTION |
| OLD | NEW |