@@ -20,13 +20,14 @@ local function negotiate(s, options, timeout)
2020 if tls then
2121 local ctx = options .ctx or default_ctx
2222 local ssl = openssl_ssl .new (ctx )
23- local ip = options .host and http_util .is_ip (options .host )
24- if options .sendname ~= nil then
25- if options .sendname then -- false indicates no sendname wanted
26- ssl :setHostName (options .sendname )
27- end
28- elseif options .host and not ip then
29- ssl :setHostName (options .host )
23+ local host = options .host
24+ local host_is_ip = host and http_util .is_ip (host )
25+ local sendname = options .sendname
26+ if sendname == nil and not host_is_ip and host then
27+ sendname = host
28+ end
29+ if sendname then -- false indicates no sendname wanted
30+ ssl :setHostName (sendname )
3031 end
3132 if http_tls .has_alpn then
3233 if version == nil then
@@ -40,12 +41,12 @@ local function negotiate(s, options, timeout)
4041 if version == 2 then
4142 ssl :setOptions (openssl_ctx .OP_NO_TLSv1 + openssl_ctx .OP_NO_TLSv1_1 )
4243 end
43- if options . host and http_tls .has_hostname_validation then
44+ if host and http_tls .has_hostname_validation then
4445 local params = openssl_verify_param .new ()
45- if ip then
46- params :setIP (options . host )
46+ if host_is_ip then
47+ params :setIP (host )
4748 else
48- params :setHost (options . host )
49+ params :setHost (host )
4950 end
5051 -- Allow user defined params to override
5152 local old = ssl :getParam ()
0 commit comments