Why do you want to check what the server wants? This request is done over https, just ask for a certificate.
If I remember well, the server owes nothing to anyone. It is the responsibility of the client to start communicating with SSL handshaking, and the client / server to exchange certificates before the real connection with HTTP occurs. You cannot determine if the server requires a certificate. If you try to talk to him, and if you do not start with a certificate, and if the server wants to receive a certificate, the server will disconnect and remain silent, or perhaps it will return some random error code.
You can try to detect early detection if the server tries to do a handshake before trying to create / send a request for it, but you will need to make the layer lower, at the TCP level. Try checking out the RFCs that describe HTTPS negotiations or the handshake prefix, maybe this will help you a bit.
Or just try making an HTTP request without an S request, and if it fails, retry the request with the certificate request and try again using HTTPS. I think your users will survive.
source share