How can I establish a secure channel for SSL/TLS from a handheld device?

前端 未结 2 1547
被撕碎了的回忆
被撕碎了的回忆 2020-12-18 08:37

I am trying to call a REST method from a handheld device (Windows CE / Compact framework) with this code:

public static HttpWebRequest SendHTTPRequestNoCrede         


        
2条回答
  •  没有蜡笔的小新
    2020-12-18 09:35

    The .NET Compact Framework does not have ServerCertificateValidationCallback.
    What you could do is to set a CertificatePolicy class to validate the certificate.

    public class TrustAllCertificatePolicy : ICertificatePolicy
    {
      public TrustAllCertificatePolicy()
      {
      }
    
      public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem)
      {
        return true;
      }
    }
    
    ...
    
    System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
    

    See this link for more information.

提交回复
热议问题