python中的握手失败(_ssl.c:590) [英] HandShake Failure in python(_ssl.c:590)

查看:89
本文介绍了python中的握手失败(_ssl.c:590)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下行时,

req = urllib2.Request(requestwithtoken) 
self.response = urllib2.urlopen(req,self.request).read()

我收到以下异常:

SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

问题是我可以通过使用 curl ping 服务来获取令牌.在检索令牌的过程中,所有证书都经过验证.反过来,通过使用生成的令牌,我无法连接到服务.尝试时出现上述错误.这可能是什么原因?

The thing is I am able to get the token by pinging the service by using curl. During the process of retrieving the token, all the certificates were verified. In turn, by using the generated token, i am not able to connect to the service. I am getting the above error while trying. What could be the reason for that?

推荐答案

我遇到了同样的问题.这可能是因为您的远程服务器请求了 urllib2 不支持的密码.我认为有两种可能的解决方案:

I was having the same issue. It's probably because your remote server requests cipher that isn't supported by urllib2. I think there're two solutions possible:

  1. urllib<中启用您的特定密码.我认为您还可以启用 所有支持的密码(请参阅页面底部),而是通过 curl 检查您使用的是哪个,如上面的链接所示.

  1. Enable your specific cipher in urllib. I think you can also enable all ciphers supported (see the very bottom of the page) but rather check which one you're using with curl as shown in the link above.

安装带有额外安全包的 requests 使用:pip install requests[security].在这个github上的请求问题中进一步讨论了这一点.

Install requests with extra security packages using: pip install requests[security]. It's further discussed in this requests issue on github.

我做了第二个选项,它对我有用.

I did the second option and it worked for me.

这篇关于python中的握手失败(_ssl.c:590)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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