贝宝-ASP.NET中等信任度 [英] PayPal - ASP.NET Medium Trust

查看:144
本文介绍了贝宝-ASP.NET中等信任度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我们的Web托管提供商已将所有共享的ASP.NET网站托管的信任级别提高到中等.结果,我们在通过PayPal的SOAP API完成交易时遇到了一些问题.具体来说,正在使用以下堆栈跟踪引发SecurityException异常:

Recently our Web hosting provider moved to a medium trust level for all shared ASP.NET site hosting. As a result, we're having some issues completing transactions via PayPal's SOAP API. Specifically, a SecurityException exception is being thrown with the following stack trace:

[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
...

我在PayPal SOAP SDK中找到了有问题的方法的源.

I tracked down the source to the offending method in the PayPal 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

是否知道需要进行哪些更改才能使SDK在中等信任环境中运行?是否必须接受所有不受信任的证书?

Does any know what change(s) need to be made to allow the SDK to function in a medium trust environment? Is it a necessity that all un-trusted certificates be accepted?

谢谢.

推荐答案

您可以要求您的ISP向GAC提供PayPal程序集-这样,它们就可以完全信任地运行(假设它们在程序集上设置了允许部分受信任的调用者"属性)

You could ask your ISP to GAC the PayPal assemblies - that way they run in full trust (assuming they have the allow partially trusted callers attribute set on the assembly).

Medium Trust的另一个问题是它不允许传出的网络连接,包括SOAP调用.

The other problem you'll have with Medium Trust is that it doesn't allow outgoing network connections, including SOAP calls.

这篇关于贝宝-ASP.NET中等信任度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆