private static void SetCertificatePolicy() { if( ServicePointManager.ServerCertificateValidationCallback==null){ ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate; } } /// <summary> /// 遠程證書驗證,固定返回true /// </summary> private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) { return true; }
在linux上使用mono發起https的請求,發現會會有ssl錯誤,搜索後在stackoverflow上搜索所得,在發起請求錢加上全局的注冊,這樣就可以防止出錯。注冊一次即可,無需多次。