CertificateError: hostname doesn't match

前端 未结 3 1373
一向
一向 2021-02-13 05:50

I\'m using a proxy (behind corporate firewall), to login to an https domain. The SSL handshake doesn\'t seem to be going well:

CertificateError: hostname \'ats.f         


        
3条回答
  •  深忆病人
    2021-02-13 06:42

    In my case the certificate's DNS name was ::1 (for local testing purposes) and hostname verification failed with

    ssl.CertificateError: hostname '::1' doesn't match '::1'
    

    To fix it somewhat properly I monkey patched ssl.match_hostname with

    import ssl                                                                                                                                                                                             
    ssl.match_hostname = lambda cert, hostname: hostname == cert['subjectAltName'][0][1]
    

    Which actually checks if the hostnames match.

提交回复
热议问题