最近,我們的網站託管服務提供商移動到所有共享ASP.NET網站託管的中等信任級別。因此,我們在通過PayPal的SOAP API完成交易時遇到了一些問題。具體而言,一個SecurityException異常被拋出與以下堆棧跟蹤:貝寶 - ASP.NET中等信託
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Net.ServicePointManager.set_CertificatePolicy(ICertificatePolicy value) +54
com.paypal.sdk.core.APICallerBase.SetTrustManager() +30
com.paypal.sdk.core.soap.SOAPAPICaller..ctor() +14
com.paypal.sdk.services.CallerServices..ctor() +23
...
我找到了源於貝SOAP SDK違規方法。
/// <summary>
/// To Accept all un-trusted certificate
/// </summary>
private void SetTrustManager()
{
//This code is added to accept all un-trusted certificate i.e self-signed certificate
if (Config.Instance.TrustAll)
{
//ServicePointManager.CertificatePolicy = TrustAllCertificatePolicy.Instance;
ServicePointManager.CertificatePolicy = new MyPolicy();
}
} // SetTrustManager
是否有知道什麼變化率(s)需要作出允許SDK在中等信任環境中發揮作用?是否有必要接受所有不可信任的證書?
謝謝。