简体   繁体   English

在python中使用请求时,出现以下错误“ TLSV1_ALERT_PROTOCOL_VERSION”。为什么会发生这种情况?

[英]When using requests in python I'm given the following error “TLSV1_ALERT_PROTOCOL_VERSION.” Why might this be happening?

This is my code so far. 到目前为止,这是我的代码。 When using requests in Python I'm given the following error: 在Python中使用请求时,出现以下错误:

TLSV1_ALERT_PROTOCOL_VERSION.

Why might this be happening? 为什么会这样呢?

import requests

def lambda_handler(event, context):

     # context = ssl.OPENSSL_VERSION_INFO

     # print(context)
     # if event['session']['application']['applicationId'] != app_id:
     #     raise ValueError("Invalid Application ID")

     token = requests.post(html, data={'apikey': api_key}, auth=(username, password), verify=False)

     print(token.text)
     payload = {'token': token}

     requests.post(html_step_two, data=payload,  verify=False)

     payload = {'token': token, 'workflow_id': workflow_id}
     requests.post(workflow_run, data=payload,  verify=False)

     return 'Hello from Lambda'

You don't mention which version of openSSL you use, but it is likely the culprit! 您没有提到使用哪个版本的openSSL,但这很可能是罪魁祸首! It's a fairly common issue, and one that seems to be best resolved by clean installs of both openSSL and Python. 这是一个相当普遍的问题,似乎最好通过全新安装openSSL和Python来解决。

To check which version of openSSL you are using, go to your Python terminal and type 要检查您使用的是哪个版本的openSSL,请转到您的Python终端并输入

import platform
import ssl

print("Python info: %s" % (platform.python_version()))
print("OpenSSL info: %s" % (ssl.OPENSSL_VERSION))

If the OpenSSL info is returned as being OpenSSL 0.9.8zh 14 Jan 2016 , you may experience issues. 如果OpenSSL信息作为OpenSSL 0.9.8zh 14 Jan 2016返回,则可能会遇到问题。 On my mac, this returns OpenSSL 1.0.2j 26 Sep 2016 , which works with other requests applications I've used in the past. 在我的Mac上,这将返回OpenSSL 1.0.2j 26 Sep 2016 ,可与我过去使用的其他请求应用程序一起使用。

The solution at this point would probably be to uninstall openSSL and reinstall it! 此时的解决方案可能是卸载openSSL并重新安装它! However, you would also probably want to upgrade your installation of brew, as it is likely not benefitting from an update released last September concerning OpenSSL. 但是,您可能还想升级brew的安装,因为它可能无法从去年9月发布的有关OpenSSL 的更新中受益

After looking at a few examples on the web, I believe the most straight-forward and comprehensive way to reinstall openssl and upgrade brew (assuming there are not any other issues) is by running: 在查看了网上的一些示例之后,我相信重新安装openssl和升级brew的最直接,最全面的方法(假设没有其他问题)是通过运行:

brew uninstall openssl

and

brew update && brew upgrade && brew cleanup && brew doctor

taking the time to fix any issues brought up by brew doctor , before finally running 在最终运行之前,花时间修复brew doctor提出的任何问题

brew install openssl

This will ensure you are running the latest version of OpenSSL, and should help resolve the issue! 这将确保您正在运行最新版本的OpenSSL,并应有助于解决该问题!

A side note here, upgrading Homebrew will update all your installed packages to their latest versions. 在此处的补充说明, 升级Homebrew会将所有已安装的软件包更新为最新版本。 This may not be ideal for you if some of your other coding projects are dependent on now-deprecated packages included in previous versions of brew . 如果您的某些其他编码项目依赖于brew版本中现已弃用的软件包,那么这对于您可能不是理想的。 I wouldn't think it to be a large problem, but just an FYI! 我认为这不会是一个大问题,而只是一个供参考!

If this uninstall of OpenSSL doesn't work for you, there are other ways , but I would imagine there to be larger problems if the above solution doesn't work. 如果此OpenSSL卸载对您不起作用,则有其他方法 ,但是我可以想象,如果上述解决方案不起作用,则会出现更大的问题。

Hope it helps! 希望能帮助到你!

Sources 资料来源

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TLSV1_ALERT_PROTOCOL_VERSION 与 python 请求包 - TLSV1_ALERT_PROTOCOL_VERSION with python requests package Python - Docker 客户端连接中的 tlsv1 警报协议版本错误 - Python - tlsv1 alert protocol version error in Docker client connection 使用pip安装python软件包时出错(TLSV1_ALERT_PROTOCOL_VERSION) - Error installing python package with pip (TLSV1_ALERT_PROTOCOL_VERSION) requests.exceptions.SSLError:[SSL:TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version(_ssl.c:590) - requests.exceptions.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) 无法在 Ubuntu Linux 中使用 pip 安装 Python 包:InsecurePlatformWarning、SSLError、tlsv1 警报协议版本 - Unable to install Python packages using pip in Ubuntu Linux: InsecurePlatformWarning, SSLError, tlsv1 alert protocol version 为什么在使用Python请求而不使用cURL时会出现500错误 - Why might I be getting a 500 Error when using Python Requests, but not using cURL 无法安装 Python 包 [SSL: TLSV1_ALERT_PROTOCOL_VERSION] - Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION] Python HTTPS/SSL 错误:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 警报协议版本 - Python HTTPS/SSL error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version Python 请求获取 TLSV1_ALERT_INTERNAL_ERROR - Python requests gets TLSV1_ALERT_INTERNAL_ERROR OpenSSL:错误:1409442E:SSL 例程:ssl3_read_bytes:tlsv1 警报协议版本 - OpenSSL: error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM