0

I have some legacy code on F#

                let response = 
                    Http.Request (
                        ArtifactoryUrl, 
                        silentHttpErrors = true,
                        httpMethod = "POST", 
                        body = HttpRequestBody.TextRequest requestJson,
                        headers = [ 
                            HttpRequestHeaders.BasicAuth ArtifactoryUserName ArtifactoryPassword
                            HttpRequestHeaders.ContentType "application/json"
                            HttpRequestHeaders.Accept "application/json"
                        ]
                    )

Starting from some time, it failed with the following error

exception: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

I suspect that it is due to recent web server limitation to TLS 1.2 only. How can i fix it? How can i select TLS1.2 only? Any help here will highly appreciated!

user41995
  • 129
  • 1
  • 3
  • 7

1 Answers1

1

I believe it happens because you are using old version of .net framework (less than 4.7). If so, you can set the default and fallback versions for outbound calls using the ServicePointManager:

ServicePointManager.SecurityProtocol <- SecurityProtocolType.Tls12 ||| SecurityProtocolType.Tls11

You can find more details here