C# HttpClient with X509Certificate2 - WebException: The request was aborted: Could not create SSL/TLS secure channel

前端 未结 2 1073
情歌与酒
情歌与酒 2021-01-17 05:02

I\'m working on implementing a payment service called Swish and testing it using this guide (Guide is in English even though filename is Swedish).

https://www.getswi

2条回答
  •  囚心锁ツ
    2021-01-17 05:21

    You can attach eventHandler to ServicePointManager like this:

    ServicePointManager.ServerCertificateValidationCallback = ForcedAuthDelegate;
    

    and implementation of ForcedAuthDelegate should return true to accept connection:

            static bool ForcedAuthDelegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return true;
            }
    

提交回复
热议问题