2009-05-28 81 views
0

我們的客戶在質量保證環境中存在不匹配的SSL證書。我們正在使用Azure Web角色對這些受SSL保護的Web資源進行HttpWebRequest調用。爲了繞過他們的證書,我們將ServicePointManager.CertificatePolicy設置爲接受所有證書的新策略。這可以在完全信任的環境中運行,但是當我們嘗試在低於完全信任的Azure環境中設置CertificatePolicy時,會出現SecurityPermission異常。有沒有辦法讓我們可以在Azure服務中使用這些調用?SSL HttpWebRequest到Azure上存在不匹配證書的站點?

回答

0

我會回答我自己的問題!

顯然,要完全信任地運行它,只需在Web角色配置中啓用enableNativeCodeExecution =「true」即可。

0

請問這是什麼?

System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate (
    object sender, 
    X509Certificate cert, 
    X509Chain chain, 
    SslPolicyErrors sslPolicyErrors) 
{ 
    if (sslPolicyErrors == SslPolicyErrors.None) 
    { 
     return true; //Is valid 
    } 
    //Add the mismatched certificate hashstring below. 
    //That way only that resource will be affected and not all certificates will be trusted. 
    if (cert.GetCertHashString() == "99E92D8447AEF30483B1D7527812C9B7B3A915A7") 
    { 
     return true; 
    } 

    return false; 
};