【问题标题】:SSL Errors for ssl.get_server_certificate on some websites but not on others某些网站上的 ssl.get_server_certificate 的 SSL 错误,但在其他网站上却没有
【发布时间】:2022-02-05 01:11:20
【问题描述】:

所以我尝试使用以下方法获取一些域证书:(首先从 nmap 检索端口,然后尝试使用 443)

ssl.get_server_certificate((hostname, port))

但对于某些域,例如以下域(仅其中几个):q1.insightsnow.redbull.com、mib-cdn.redbull.com、internalauditdb-uux-d.redbull.com、smg20.redbull。 com,ssmg11-q.redbull.com,pm.redbull.com。 对于这个子域和许多其他子域,我收到了一堆不同的错误:

  • [SSL: WRONG_VERSION_NUMBER] 版本号错误
  • 超时
  • EOF 发生违反协议
  • [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败

我需要提一下,对于许多其他子域(大约 1000 个),一切正常,我可以获得他们的证书。但是对于其中的大约 200 个,我反复从上面收到错误,我无法在互联网上找到它们的来源。

你知道为什么我不能在那些网站上使用 ssl.get_server_certificate 或者我在哪里做错了吗?

谢谢!

【问题讨论】:

    标签: python ssl server openssl tls1.2


    【解决方案1】:

    如果这里的站点需要 SNI,则大多数情况下。这是一个长期存在的问题,SNI 没有使用 ssl.get_server_certificate - 请参阅 ssl.get_server_certificate for sites with SNI (Server Name Indication)Python issue 36076。终于用3.10解决了:

    $ python3.8 -c 'import ssl; print(ssl.get_server_certificate(("q1.insightsnow.redbull.com", 443)))'
    ...
    ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)
    
    
    $ python3.10 -c 'import ssl; print(ssl.get_server_certificate(("q1.insightsnow.redbull.com", 443)))'
    -----BEGIN CERTIFICATE-----
    MIIHnjCCBoagAwIBAgIRAPcBO50Fz5QaF+JxeyoL1vEwDQYJKoZIhvcNAQELBQAw
    gZUxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO
    ...
    

    对于较旧的 Python 版本,请参阅this question 的答案,了解如何在不使用 ssl.get_server_certificate 的情况下获取证书。

    至于 smg20.redbull.com 和 ssmg11-q.redbull.com - 这些网站一开始似乎无法通过互联网访问,即其他工具或浏览器也无法访问它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      • 2020-07-20
      • 2015-12-13
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多