代码之家  ›  专栏  ›  技术社区  ›  Mike Flynn

请求已中止:无法创建SSL/TLS安全通道,但可通过浏览器/邮递员工作

  •  9
  • Mike Flynn  · 技术社区  · 7 年前

    我在这里有点迷路了。添加ServicePointManager的东西通常可以解决这个问题,但这一次我不断地得到下面的错误。我的服务器可以通过浏览器和邮递员访问相同的URL。但是在网站上运行这个功能失败了。这在我的本地计算机上运行。我在服务器上启用了TLS 1.1和TLS 1.2。

    https://www.ssllabs.com/ssltest/analyze.html?d=basketball.exposureevents.com

    我正在使用CertifyTheWeb证书,基本上是免费的SSL。不确定这是否与此有关。

    我正在发送到下面的链接,当从IIS下面的代码发出请求时,该链接将拒绝该请求。

    https://www.nationalsportsid.com/tournament/6028

    消息:请求被中止:无法创建SSL/TLS安全 频道来源:系统堆栈跟踪:在 System.Net.HttpWebRequest.GetResponse()位于

    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
    
    var webRequest = (HttpWebRequest) WebRequest.Create("https://www.nationalsportsid.com/tournament/" + nationalSportsId);
    try
    {
        using (var webResponse = (HttpWebResponse) webRequest.GetResponse())
        {
            if (webResponse.StatusCode == HttpStatusCode.OK)
            {
                return true;
            }
        }
    }
    catch (WebException ex)
    {
        Logger.Error(ex);
    }
    

    enter image description here

    警觉的

    enter image description here

    3 回复  |  直到 7 年前
        1
  •  2
  •   Mike Flynn    7 年前

    这是Apache中另一台服务器的配置问题。他们放松了SSL配置,我不确定他们做了什么,但他们以前的配置如下。我现在可以向他们的服务器发出HTTP请求。

    SSLEngine on
    
    # Intermediate configuration, tweak to your needs
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE$
    SSLHonorCipherOrder on
    SSLCompression off
    
    SSLOptions +StrictRequire
    
        2
  •  1
  •   hoz    7 年前

    您的目标服务器可能没有为SSLv2和SSLv3配置任何密码套件。您需要检查您的客户端是否允许使用服务器上为允许的SSL协议配置的密码套件进行连接。

    在Windows使用中:

    Get-TlsCipherSuite    [[-Name] <String>]    [<CommonParameters>]
    

    https://docs.microsoft.com/en-us/powershell/module/tls/get-tlsciphersuite

    要在windows中添加密码套件,请执行以下操作:

    Enable-TlsCipherSuite
          [[-Position] <UInt32>]
          [-Name] <String>
          [-WhatIf]
          [-Confirm]
          [<CommonParameters>]
    

    参考文献- https://docs.microsoft.com/en-us/powershell/module/tls/Enable-TlsCipherSuite

    openssl ciphers [-v] [-V] [-ssl2] [-ssl3] [-tls1] [cipherlist]
    

    参考文献- https://linux.die.net/man/1/ciphers

        3
  •  0
  •   Gonzalo A.    7 年前

    我会先尝试使用 (LinuxBox或cygwin)。

    你的第一步可能是这样的

    $ echo | openssl s_client -connect www.nationalsportsid.com:443 -tls1_2
    CONNECTED(00000003)
    depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3
    verify return:1
    depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
    verify return:1
    depth=0 CN = www.nationalsportsid.com
    verify return:1
    ---
    Certificate chain
     0 s:/CN=www.nationalsportsid.com
       i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
     1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
       i:/O=Digital Signature Trust Co./CN=DST Root CA X3
    ---
    Server certificate
    -----BEGIN CERTIFICATE-----
    MIIGTDCCBTSgAwIBAgISBIrqOzNTV7HxnH4SauB/Zeq2MA0GCSqGSIb3DQEBCwUA
    MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
    ...
    

    请检查这个 how to connect to https protocol using openssl