gpt4 book ai didi

python - OpenSSL 错误 - RestClient Gem - Python WSGI

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

问题:

我正在努力解决 SSL 问题。我正在尝试连接到 Python 应用程序的 Web 服务器,但每次执行请求时,都会出现此错误:

RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=error: certificate verify failed:

详情:

  • 我使用 RestClient gem (v1.8.0)并且正在尝试一个简单的 GET 请求
  • python code to launch the server是这样的:

    http_server = WSGIServer(('', int(port)), app, log=nylas_logger, handler_class=NylasWSGIHandler,
    keyfile='/vagrant/server.key', certfile='/vagrant/server.crt')

  • 我在另一台服务器 (Nginx Passenger) 的另一个子域上使用相同的证书(通配符证书 COMODO),我可以成功启动我的请求

我试过的:

  • 我尝试使用 Brew 重新安装 Openssl
  • 我成功启动了将 verify_ssl: false 标志传递给 restclient gem 的请求(但我想找到一个不使用此解决方法的解决方案)
  • 我尝试使用 --disable-bynary 标志重新安装 Ruby(我正在使用 RVM)
  • 我启动了 rvm osx-ssl-certs update all

最令人惊讶的是,我实际上可以使用相同的证书在另一种类型的服务器上执行请求,所以看来问题可能出在 Python 网络服务器上。

最佳答案

事实证明 gevent.pywsgi 服务器没有正确处理 SSL 证书。我安装了 Nginx 并在本地主机 Python gevent.pywsgi 服务器上做了一个反向代理,并在 Nginx 部分做了 SSL 处理,它立即工作。

有关信息,我的 nginx conf :

server{
listen 80;
return 301 https://$host$request_uri;
}

server{
listen 443;
server_name subdomain.domain.com;
ssl on;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proro $scheme;

proxy_pass http://localhost:5555;
proxy_read_timeout 90;
proxy_pass_request_headers on;

proxy_redirect http://localhost:5555 https://subdomain.domain.com;
}
}

而且我限制 python 服务器只监听本地主机请求。

关于python - OpenSSL 错误 - RestClient Gem - Python WSGI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38914068/

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