Windows上的Python:ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败

时间:2018-09-17 14:52:37

标签: python python-3.x ssl rabbitmq

在Windows上进行了某些设置rabbitmqadmin,现在当我们运行应创建队列的作业时,脚本会由于ssl问题而失败

11:27:12 Traceback (most recent call last):
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 535, in http
11:27:12     conn.request(method, path, body, headers)
11:27:12   File "http\client.py", line 1239, in request
11:27:12   File "http\client.py", line 1285, in _send_request
11:27:12   File "http\client.py", line 1234, in endheaders
11:27:12   File "http\client.py", line 1026, in _send_output
11:27:12   File "http\client.py", line 964, in send
11:27:12   File "http\client.py", line 1400, in connect
11:27:12   File "ssl.py", line 401, in wrap_socket
11:27:12   File "ssl.py", line 808, in __init__
11:27:12   File "ssl.py", line 1061, in do_handshake
11:27:12   File "ssl.py", line 683, in do_handshake
11:27:12 ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)
11:27:12 
11:27:12 During handling of the above exception, another exception occurred:
11:27:12 
11:27:12 Traceback (most recent call last):
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 1066, in <module>
11:27:12     main()
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 447, in main
11:27:12     method()
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 638, in invoke_list
11:27:12     format_list(self.get(uri), cols, obj_info, self.options)
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 477, in get
11:27:12     return self.http("GET", "%s/api%s" % (self.options.path_prefix, path), "")
11:27:12   File "D:\jenkins\home\workspace\RabbitMQ-BUILD\target\classes\rabbitmqadmin", line 537, in http
11:27:12     traceback.print_exc(e)
11:27:12   File "traceback.py", line 159, in print_exc
11:27:12   File "traceback.py", line 100, in print_exception
11:27:12   File "traceback.py", line 497, in __init__
11:27:12   File "traceback.py", line 332, in extract
11:27:12 TypeError: '>=' not supported between instances of 'ssl.SSLError' and 'int'

当我在其中检查ssl配置时,我看到一些路径(openssl_cafile,openssl_capath),这些路径在Windows中显然不存在

>>> print(ssl.get_default_verify_paths())
DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/usr/local/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/usr/local/ssl/certs')

不幸的是,我是python和Rabbitmq新手,由于我没有设置整个程序,所以我陷入了困境。我试图了解如何解决问题,从而不再出现ssl错误

  1. 配置错误的地方
  2. 您在哪里为Windows配置python的认证路径

这是我所知道的:

我们使用自签名证书(必须)。

rabbitmq.config中与SSL相关的配置如下

 {ssl_options, [{cacertfile,           "D:\\RabbitMQ\\rabbitmqca.pem"},
            {certfile,             "D:\\RabbitMQ\\myhost_listener.pem"},
            {keyfile,              "D:\\RabbitMQ\\myhost_listener_key.pem"},
            {verify,               verify_peer},
            {fail_if_no_peer_cert, false}]},

0 个答案:

没有答案