gpt4 book ai didi

python - python3中的ssl证书和https连接

转载 作者:太空宇宙 更新时间:2023-11-03 14:33:10 25 4
gpt4 key购买 nike

我正在尝试在 python 中使用 OpenSSL 包来构建 ssl 安全连接,但出现此错误:

socket.gaierror: [Errno 11004] getaddrinfo failed

conn.connect()

我调试了2天,网址是正确的,谁能看看是什么原因?

from OpenSSL import SSL

certi_file = p12.get_certificate() # (signed) certificate object
key_file =p12.get_privatekey() # private key.
ca_cert = p12.get_ca_certificates() # ca chain.

# ctx = Context(SSLv23_METHOD);
context = SSL.Context(SSL.TLSv1_2_METHOD)
context.set_options(SSL.OP_NO_SSLv2)
context.use_certificate(certi_file);
context.use_privatekey(key_file);
context.verify_mode = ssl.CERT_NONE;
context.check_hostname = None
context.set_verify(VERIFY_PEER | VERIFY_FAIL_IF_NO_PEER_CERT |
VERIFY_CLIENT_ONCE,verify_callback)

conn = http.client.HTTPSConnection("https//:markets.midwestiso.org/darteor/xml/submit", 80, context=context)
conn.connect()

最佳答案

您的链接 ("https//:markets.midwestiso.org/darteor/xml/submit") 似乎不正确。不应该像 “https://markets.midwestiso.org/darteor/xml/submit”。

关于python - python3中的ssl证书和https连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50730192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com