python-3.x - 使用 twine 将 python 包上传到自定义注册表时出现 SSL 错误
问题描述
当尝试将 python 自定义包上传到我们的内部注册表时,它失败并出现以下错误。
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='custom-nexus.com’, port=443): Max retries exceeded with url: /repository/pypi-internal/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))
但是通过 curl 访问时,相同的 url 可以正常工作。使用 curl -v 选项发现使用的 ca-bundle 位于 /etc/pki/tls/certs/ca-bundle.crt 位置
所以尝试使用 --cert 选项在 twine 上传命令中提供这个。但随后它也无法正常工作并因同样的错误而失败。
twine upload --config-file .pypirc --cert /etc/pki/tls/certs/ca-bundle.crt -r pypi dist/*
使用的 Python 版本是 3.6。请在下面的库版本列表中找到。
certifi==2020.4.5
setuptools==46.1.3
wheel==0.34.2
twine==3.1.1
pyOpenSSL==19.1.0
解决方案
由于某种原因,即使在使用 --cert 选项提供证书后,它也对我不起作用。证书可能有问题。然后我遇到了下面的黑客在 python 请求库中跳过 ssl 验证
(对于任何不知道的人,引擎盖下的 TWINE 也使用 python 请求库)
在此之后,我尝试了以下命令并且它有效!
export CURL_CA_BUNDLE="" && twine upload ...
推荐阅读
- html - 是否可以在切断边框的同时在div边框的左上角添加图像?
- html - 从数据库字段中剥离 HTML 以显示在查看页面上
- xpath - JSNAPY:有没有办法测试 xpath 节点属性
- javascript - 使用 div 中的按钮关闭带有母版页的 ASP.NET 页面上的 DIV,其中 JQuery 用于显示 div
- ios - 如何根据 iPhone 向上移动文本字段。尺寸迅速
- javascript - Swiper Slider - 视频结束时继续下一张幻灯片
- javascript - 如何在反应中加载自定义prismjs语法文件?
- regex - Hive regexp_replace
- c# - Xamarin.Forms - 如何制作点击计数器?
- aws-amplify - AWS Amplify 构建过程中的缓存工件是什么?