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

Side by Side Diff: runtime/bin/secure_socket.cc

Issue 1308773005: Fix hostname checking problem in SecureSocket (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | tests/standalone/io/certificates/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/certificates/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698