| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bin/secure_socket.h" | 5 #include "bin/secure_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 SSL_set_ex_data(ssl_, filter_ssl_index, this); | 873 SSL_set_ex_data(ssl_, filter_ssl_index, this); |
| 874 | 874 |
| 875 if (is_server_) { | 875 if (is_server_) { |
| 876 // Do not request a client certificate. | 876 // Do not request a client certificate. |
| 877 // TODO(24069): Allow server to request a client certificate, when desired. | 877 // TODO(24069): Allow server to request a client certificate, when desired. |
| 878 SSL_set_verify(ssl_, SSL_VERIFY_NONE, NULL); | 878 SSL_set_verify(ssl_, SSL_VERIFY_NONE, NULL); |
| 879 } else { | 879 } else { |
| 880 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false); | 880 SetAlpnProtocolList(protocols_handle, ssl_, NULL, false); |
| 881 // Sets the hostname in the certificate-checking object, so it is checked | 881 // Sets the hostname in the certificate-checking object, so it is checked |
| 882 // against the certificate presented by the server. | 882 // against the certificate presented by the server. |
| 883 X509_VERIFY_PARAM* certificate_checking_parameters_ = SSL_get0_param(ssl_); | 883 X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_); |
| 884 hostname_ = strdup(hostname); | 884 hostname_ = strdup(hostname); |
| 885 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters_, 0); | 885 X509_VERIFY_PARAM_set_hostflags(certificate_checking_parameters, 0); |
| 886 X509_VERIFY_PARAM_set1_host(certificate_checking_parameters_, | 886 X509_VERIFY_PARAM_set1_host(certificate_checking_parameters, |
| 887 hostname_, 0); | 887 hostname_, strlen(hostname_)); |
| 888 // TODO(24225) Check return value of set1_host(). |
| 888 // TODO(24186) free hostname_ if it is not freed when SSL is destroyed. | 889 // TODO(24186) free hostname_ if it is not freed when SSL is destroyed. |
| 889 // otherwise, make it a local variable, not a instance field. | 890 // otherwise, make it a local variable, not a instance field. |
| 890 } | 891 } |
| 891 // Make the connection: | 892 // Make the connection: |
| 892 if (is_server_) { | 893 if (is_server_) { |
| 893 status = SSL_accept(ssl_); | 894 status = SSL_accept(ssl_); |
| 894 if (SSL_LOG_STATUS) Log::Print("SSL_accept status: %d\n", status); | 895 if (SSL_LOG_STATUS) Log::Print("SSL_accept status: %d\n", status); |
| 895 if (status != 1) { | 896 if (status != 1) { |
| 896 // TODO(whesse): expect a needs-data error here. Handle other errors. | 897 // TODO(whesse): expect a needs-data error here. Handle other errors. |
| 897 error = SSL_get_error(ssl_, status); | 898 error = SSL_get_error(ssl_, status); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 } else { | 1104 } else { |
| 1104 if (SSL_LOG_DATA) Log::Print( | 1105 if (SSL_LOG_DATA) Log::Print( |
| 1105 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed); | 1106 "WriteEncrypted BIO_read wrote %d bytes\n", bytes_processed); |
| 1106 } | 1107 } |
| 1107 } | 1108 } |
| 1108 return bytes_processed; | 1109 return bytes_processed; |
| 1109 } | 1110 } |
| 1110 | 1111 |
| 1111 } // namespace bin | 1112 } // namespace bin |
| 1112 } // namespace dart | 1113 } // namespace dart |
| OLD | NEW |