OLD | NEW |
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 "net/socket/ssl_client_socket_mac.h" | 5 #include "net/socket/ssl_client_socket_mac.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #include <netdb.h> | 8 #include <netdb.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 // | 602 // |
603 // Strictly speaking, we should check if we have received the close_notify | 603 // Strictly speaking, we should check if we have received the close_notify |
604 // alert message from the server, and return false in that case. Although | 604 // alert message from the server, and return false in that case. Although |
605 // the close_notify alert message means EOF in the SSL layer, it is just | 605 // the close_notify alert message means EOF in the SSL layer, it is just |
606 // bytes to the transport layer below, so | 606 // bytes to the transport layer below, so |
607 // transport_->socket()->IsConnectedAndIdle() returns the desired false | 607 // transport_->socket()->IsConnectedAndIdle() returns the desired false |
608 // when we receive close_notify. | 608 // when we receive close_notify. |
609 return completed_handshake() && transport_->socket()->IsConnectedAndIdle(); | 609 return completed_handshake() && transport_->socket()->IsConnectedAndIdle(); |
610 } | 610 } |
611 | 611 |
612 int SSLClientSocketMac::GetPeerAddress(AddressList* address) const { | 612 int SSLClientSocketMac::GetPeerAddress(IPEndPoint* address) const { |
613 return transport_->socket()->GetPeerAddress(address); | 613 return transport_->socket()->GetPeerAddress(address); |
614 } | 614 } |
615 | 615 |
616 int SSLClientSocketMac::GetLocalAddress(IPEndPoint* address) const { | 616 int SSLClientSocketMac::GetLocalAddress(IPEndPoint* address) const { |
617 return transport_->socket()->GetLocalAddress(address); | 617 return transport_->socket()->GetLocalAddress(address); |
618 } | 618 } |
619 | 619 |
620 const BoundNetLog& SSLClientSocketMac::NetLog() const { | 620 const BoundNetLog& SSLClientSocketMac::NetLog() const { |
621 return net_log_; | 621 return net_log_; |
622 } | 622 } |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 if (status) | 877 if (status) |
878 return NetErrorFromOSStatus(status); | 878 return NetErrorFromOSStatus(status); |
879 return OK; | 879 return OK; |
880 } | 880 } |
881 | 881 |
882 // Concatenate the hostname and peer address to use as the peer ID. To | 882 // Concatenate the hostname and peer address to use as the peer ID. To |
883 // resume a session, we must connect to the same server on the same port | 883 // resume a session, we must connect to the same server on the same port |
884 // using the same hostname (i.e., localhost and 127.0.0.1 are considered | 884 // using the same hostname (i.e., localhost and 127.0.0.1 are considered |
885 // different peers, which puts us through certificate validation again | 885 // different peers, which puts us through certificate validation again |
886 // and catches hostname/certificate name mismatches. | 886 // and catches hostname/certificate name mismatches. |
887 AddressList address; | 887 IPEndPoint endpoint; |
888 int rv = transport_->socket()->GetPeerAddress(&address); | 888 int rv = transport_->socket()->GetPeerAddress(&endpoint); |
889 if (rv != OK) | 889 if (rv != OK) |
890 return rv; | 890 return rv; |
891 const IPEndPoint& endpoint = address.front(); | |
892 std::string peer_id(host_and_port_.ToString()); | 891 std::string peer_id(host_and_port_.ToString()); |
893 peer_id += std::string(reinterpret_cast<const char*>(&endpoint.address()[0]), | 892 peer_id += std::string(reinterpret_cast<const char*>(&endpoint.address()[0]), |
894 endpoint.address().size()); | 893 endpoint.address().size()); |
895 // SSLSetPeerID() treats peer_id as a binary blob, and makes its | 894 // SSLSetPeerID() treats peer_id as a binary blob, and makes its |
896 // own copy. | 895 // own copy. |
897 status = SSLSetPeerID(ssl_context_, peer_id.data(), peer_id.length()); | 896 status = SSLSetPeerID(ssl_context_, peer_id.data(), peer_id.length()); |
898 if (status) | 897 if (status) |
899 return NetErrorFromOSStatus(status); | 898 return NetErrorFromOSStatus(status); |
900 | 899 |
901 return OK; | 900 return OK; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 if (rv < 0 && rv != ERR_IO_PENDING) { | 1439 if (rv < 0 && rv != ERR_IO_PENDING) { |
1441 us->write_io_buf_ = NULL; | 1440 us->write_io_buf_ = NULL; |
1442 return OSStatusFromNetError(rv); | 1441 return OSStatusFromNetError(rv); |
1443 } | 1442 } |
1444 | 1443 |
1445 // always lie to our caller | 1444 // always lie to our caller |
1446 return noErr; | 1445 return noErr; |
1447 } | 1446 } |
1448 | 1447 |
1449 } // namespace net | 1448 } // namespace net |
OLD | NEW |