【问题标题】:Paypal and asp.net on IIS with TLS1.2带有 TLS1.2 的 IIS 上的 Paypal 和 asp.net
【发布时间】:2017-12-13 06:42:39
【问题描述】:

我正在尝试将 PayPal 应用程序部署到 IIS。

由于 TLS1.2 的问题,我无法连接到 PayPal

我对注册表进行了所有更改并使用 .Net 4.6.1

如果我在控制台应用程序上使用此代码

        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        using (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse())
        using (var streamReader = new StreamReader(response.GetResponseStream()))
        {
            Console.WriteLine(streamReader.ReadToEnd());
        }

它有效。

将相同的代码放入 asp.net 应用程序并部署到同一服务器上的 IIS 不起作用。

任何想法为什么控制台应用程序可以工作而部署在 IIS 上的 asp.net 应用程序不能工作?

错误:

连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应 104.75.235.58:443 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详情:System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接主机没有响应104.75.235.58:443

来源错误:

第 16 行:System.Net.ServicePointManager.SecurityProtocol = System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 |安全协议类型.Tls11 |安全协议类型.Tls; 第 17 行: 第 18 行:使用 (var response = WebRequest.Create("https://tlstest.paypal.com/").GetResponse()) 第 19 行:使用 (var streamReader = new StreamReader(response.GetResponseStream())) 第 20 行:{

源文件:C:\WebApplication2\WebApplication2\WebForm1.aspx.cs 行:18

堆栈跟踪:

[SocketException(0x274c):连接尝试失败,因为连接方一段时间后没有正确响应,或者连接建立失败,因为连接主机没有响应104.75.235.58:443] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +185 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +506

[WebException: 无法连接到远程服务器] System.Net.HttpWebRequest.GetResponse() +1390 C:\Temp\Razno\PPtest\WebApplication2\WebApplication2\WebForm1.aspx.cs:18 中的 WebApplication2.WebForm1.Page_Load(Object sender, EventArgs e) System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者,EventArgs e)+51 System.Web.UI.Control.OnLoad(EventArgs e) +95 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

【问题讨论】:

  • Console.WriteLine 在 asp.net 应用程序中不起作用。您能否为我们提供代码,您是如何在 asp.net 应用程序中完成的
  • 正如我所说,部署在 web 表单项目中的相同代码在 aspx 页面而不是控制台中。 writleln 我已经放了字符串 a = streamReader.ReadToEnd();,但这不相关,因为应用程序没有到达 aspx 应用程序中的那个部分
  • 请添加你得到的异常和堆栈跟踪。

标签: asp.net iis paypal


【解决方案1】:

您遇到的是套接字错误,而不是 ssl 问题。

连接尝试失败,因为连接方没有 一段时间后正确响应,或建立连接 失败,因为连接的主机没有响应

您的应用程序无法连接到上述地址https://tlstest.paypal.com/。这可能是由于代理设置,您的控制台应用程序将在您的凭据下运行并继续默认代理设置,但 IIS(w3wp.exe) 不能。请尝试添加proxy settings。也请参考this

另外thisSO 帖子讨论相同

【讨论】:

    猜你喜欢
    • 2011-05-28
    • 1970-01-01
    • 2011-06-19
    • 2010-10-16
    • 2021-08-16
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    • 2016-01-25
    相关资源
    最近更新 更多