소스 검색

Don't set SNI hostname if it does not include "." for GNUTLS

Tatsuhiro Tsujikawa 13 년 전
부모
커밋
0030025bb6
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      src/SocketCore.cc

+ 4 - 1
src/SocketCore.cc

@@ -986,7 +986,10 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname)
   switch(secure_) {
   case A2_TLS_INITIALIZED:
     secure_ = A2_TLS_HANDSHAKING;
-    if(!util::isNumericHost(hostname)) {
+    // Check hostname is not numeric and it includes ".". Setting
+    // "localhost" will produce TLS alert.
+    if(!util::isNumericHost(hostname) &&
+       hostname.find(".") != std::string::npos) {
       // TLS extensions: SNI
       int ret = gnutls_server_name_set(sslSession_, GNUTLS_NAME_DNS,
                                        hostname.c_str(), hostname.size());