python中的握手失败(_ssl.c:590)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33778516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HandShake Failure in python(_ssl.c:590)
提问by Bharathi Kodeeswaran
When I execute the below line,
当我执行以下行时,
req = urllib2.Request(requestwithtoken)
self.response = urllib2.urlopen(req,self.request).read()
I am getting the following exception:
我收到以下异常:
SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)
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?
问题是我能够通过使用 ping 服务来获取令牌curl
。在检索令牌的过程中,所有证书都经过验证。反过来,通过使用生成的令牌,我无法连接到服务。尝试时出现上述错误。那可能是什么原因?
回答by martin
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:
我遇到了同样的问题。这可能是因为您的远程服务器请求了 urllib2 不支持的密码。我认为有两种可能的解决方案:
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 withcurl
as shown in the link above.Install
requests
with extra security packages using:pip install requests[security]
. It's further discussed in this requests issue on github.
在
urllib
. 我认为您还可以启用所有支持的密码(请参阅页面的最底部),而是检查您正在使用的密码,curl
如上面的链接所示。requests
使用额外的安全包安装:pip install requests[security]
. 在 github 上的这个请求问题中进一步讨论了它。
I did the second option and it worked for me.
我做了第二个选择,它对我有用。
回答by CPSuperstore
I also had the same issue. Check which version of requestsyou are using.
我也有同样的问题。检查您使用的是哪个版本的请求。
import requests
print requests.__version__
If the version is 2.18.4, you should try downgrading to version 2.11.1. I did this, and it fixed my problem. To do this, issue the following commands in the terminal
如果版本是 2.18.4,您应该尝试降级到版本 2.11.1。我这样做了,它解决了我的问题。为此,请在终端中发出以下命令
pip uninstall requests
pip install requests==2.11.1
Hope this helps.
希望这可以帮助。