I'm using winhttp in order to establish https connection on port 443 with my remote. However, the server running this service also contains more services on the same https port (443), so it uses SNI in order to resolve the requested session.
However, the server doesn't expect to get the hostname as SNI, since it uses single URL for all services. instead, the SNI address is chosen not according to the URL but according to some other string notation (i.e. service_api or service_web_if ...
)
In my client connection flow, I set the URL in method WinHttpConnect
which also set the SNI accordingly, and the actual SSL/TLS handshake is made when calling WinHttpSentRequest
.
I wonder how can I change the SNI value from the default URL value after calling WinHttpConnect
.
So far, while investigating possible solutions, I've learned about HTTP_SERVICE_CONFIG_SSL_SNI_KEY
structure which is set by method HttpSetServiceConfiguration
along with the matching certificate for this SNI, but this seems to be related to the server side configuration. Besides that, I haven't found any references for such action unfortunately.
Perhaps anybody ever used non-default SNI using winhttp
API and can tell me how to do so ? is the only option to do so is doing the SSL handshake using some lower level API such as schannel, and than switching back to winhttp
?
if it's not possible, perhaps there's an option to use extended hostname with directory tree in order to get multiple sni on a single url...