python - URL错误 : <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl. c:661)>

标签 python ssl

我收到标题中的错误

我有 python 2.7.14 和 OpenSSL 1.0.2k 2017 年 1 月 26 日

ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) #Itried all the other protocols
ctx.check_hostname = False #fails with or without these 2 lines
ctx.verify_mode = ssl.CERT_NONE
resp = urllib2.urlopen(url, context=ctx).read()

更新: 这是网址(敏感数据替换为..) https://www.upwork.com/api/hr/v2/teams/../users.json?oauth_consumer_key=..&oauth_nonce=..&oauth_signature_method=HMAC-SHA1&oauth_timestamp=..&oauth_token=..&oauth_version=1.0&tz=gmt&oauth_signature= ..

所有 key 和 token 都可以工作,因为我也在 javscript 平台上使用它们,并且它们在那里完美工作。 也可以简单地将链接粘贴到浏览器中。 但在 python 中我不知道如何调试它。有人可以帮忙吗?谢谢,深表感谢

最佳答案

ctx = ssl.SSLContext(ssl.PROTOCOL_TLS) #Itried all the other protocols

没有ssl.PROTOCOL_TLS。例如,有 ssl.PROTOCOL_TLSv1 不起作用,有 ssl.PROTOCOL_TLSv1_2 对我有用。更好的是使用ssl.create_default_context()

关于python - URL错误 : <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl. c:661)>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49545930/

相关文章:

python - 将字符串解析为类层次结构

使用 Curl 将文件发布到 Web 服务的 SSL 握手错误

c# - SslStream.AuthenticateAsClient() 使用未缓存的 CRL 非常慢

php - 一个简单的 php 脚本不适用于安全的 https 协议(protocol)

ssl - RabbitMQ - Tls 连接 - Golang

python - CountTokenizing 字段,变成列

python - 如何打印从 'startswith' 到 'endswith' 的字符串部分

python - PyObject_CallMethod有时在调用python方法时出现段错误

c# - Azure 不返回上传的证书

python - 将 Python 列表与 SQLite 表进行比较并获得差异