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

pull/28/head
Tatsuhiro Tsujikawa 2012-09-15 01:14:21 +09:00
parent 393d0d9fbc
commit 0030025bb6
1 changed files with 4 additions and 1 deletions

View File

@ -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());