且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何启用TLS 1.2

更新时间:2023-02-11 17:03:33

我根据需要在应用程序中设置了安全协议:

I set "Secure Protocol" in the app as required:
   ServicePointManager.ServerCertificateValidationCallback += ValidateCertificate;

   ServicePointManager.SecurityProtocol =
      SecurityProtocolType.Tls |
      SecurityProtocolType.Tls11 |
      SecurityProtocolType.Tls12 |
      SecurityProtocolType.Ssl3;

   try {
      // Related process.

   } finally {
      ServicePointManager.ServerCertificateValidationCallback -= ValidateCertificate;
   }

//
private static bool ValidateCertificate(
   Object sender, X509Certificate cert, X509Chain chain,
   SslPolicyErrors Errors ) {

   return true;
}