No examples are available at this time. This feature must be implemented programmatically. You can use curl to handle scenarios that require Server Name Indication (SNI).
How curl handles SNI blocking scenarios
curl has a
--resolveoption that lets you access an HTTPS website using a specified IP address.To integrate the curl library in iOS, see the curl documentation.
Note that curl also supports IPv6. To enable it, add the
--enable-ipv6flag when you build the library.curl lets you specify the SNI field. To set the SNI, construct a parameter in the following format:
{HTTPS domain name}:443:{IP address}For example, to access www.example.org with the IP address 127.0.0.1, use the following command to set the SNI:
curl --resolve 'www.example.org:443:127.0.0.1'
iOS example: The libcurl library
You can use the libcurl library to implement this solution. The curl tool has a --resolve option that lets you access an HTTPS website using a specified IP address.
The following code shows an example of an iOS implementation:
//{HTTPS domain name}:443:{IP address}
NSString *curlHost = ...;
_hosts_list = curl_slist_append(_hosts_list, curlHost.UTF8String);
curl_easy_setopt(_curl, CURLOPT_RESOLVE, _hosts_list);Here, curlHost uses the following format:
{HTTPS domain name}:443:{IP address}
_hosts_list is a struct curl_slist type. It can store multiple mappings between IP addresses and hosts. In the curl_easy_setopt method, passing the CURLOPT_RESOLVE parameter applies these mappings to the HTTPS request.
This action sets the SNI for the request.
You can find demos on GitHub that demonstrate this usage. For example, the CYLCURLNetworking demo includes a pre-compiled libcurl package with IPv6 support. It also demonstrates how to make network requests with curl in a manner similar to using NSURLSession.