libcurl为什么不为IP设置SNI?

问题描述 投票:0回答:1

我只是注意到,当我使用IP进行HTTPS呼叫时,libcurl并未设置SNI字段。我找到了:

https://github.com/curl/curl/blame/master/lib/vtls/openssl.c

#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
  if((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
     (0 == Curl_inet_pton(AF_INET6, hostname, &addr)) &&
#endif
     sni &&
     !SSL_set_tlsext_host_name(BACKEND->handle, hostname))
    infof(data, "WARNING: failed to configure server name indication (SNI) "
          "TLS extension\n");
#endif

根据Curl_inet_pton文档:

 * inet_pton(af, src, dst)
 *      convert from presentation format (which usually means ASCII printable)
 *      to network format (which is usually some kind of binary format).
 * return:
 *      1 if the address was valid for the specified address family
 *      0 if the address wasn't valid (`dst' is untouched in this case)
 *      -1 if some other error occurred (`dst' is untouched in this case, too)

按预期,它为IP地址(例如1)返回192.160.0.1,因此不调用SSL_set_tlsext_host_name

为什么?

libcurl sni
1个回答
1
投票
RFC 3546“传输层安全性(TLS)扩展” section 3.1清楚地说明了这一点:

“ HostName”中不允许使用IPv4和IPv6的实际地址。

© www.soinside.com 2019 - 2024. All rights reserved.