I am developing a winform application in which I make calls to REST webservices. For http based web servers it works fine.But,when it was used for a https based server, they recieved an exception The request was aborted: Could not create SSL/TLS secure channel.
Apparently, this is happening because they are using TLS v1.2 and I have not specified which version of protocol is to be used during webservice call.And, when I searched on internet found that adding the following code will do the job.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
But what if some other server uses different version of security protocol.How do I make the code robust, so that it detects the protocol being used and then sets the configuration accordingly?