我正在尝试运行一个连接到 myhost.comapny.com:8443 的 python 脚本,但它在运行时给出 SSL 证书错误
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1122)')))
我的代码如下:
import requests
url = "https://myhost.comapny.com:8443/environments/test/deplpyments"
payload={}
files=[
('request',('test.yaml',open('test.yaml','rb'),'application/octet-stream'))
]
headers = {
'Content-Type': 'multipart/form-data',
'Authorization': 'token'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files,verify="/user/test/company.cert")
print(response.text)
我已将证书添加为:
openssl s_client -showcerts -connect myhost.comapny.com:8443 </dev/null 2>/dev/null | openssl x509 -text >company.cert
但它仍然无法正常工作,并且出现与 SSL 验证失败相同的错误。似乎我没有正确生成证书。有人能指出我该如何正确地做到这一点吗?