生成用于python请求获取PEM lib错误的证书 [英] generating cert for use with python requests getting PEM lib error

查看:1008
本文介绍了生成用于python请求获取PEM lib错误的证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我正在使用文档进行自签名证书这里

I have an application which I'm doing self-signing certificates for using the documentation here.

应用程序将密钥库加载到jetty配置中并正确加载,并在浏览到站点时收到不可信证书的警告。

The application loads that keystore into a jetty config and loads properly and I get a warning of an untrusted certification when browsing to the site.

然后我想使用python连接到它,我已经尝试了生成证书,pem等的所有变体。我做的任何东西都让我连接。只需执行以下操作 -

Then I want to use python to connect to it and I've tried all variations of generating a cert, pem, etc. nothing I do gets me to connect. Simply doing the following -

import requests
requests.get('https://servername:8443', cert=('path\
\to\\cert\\app.cert', '\\\\path\\to\\keystore\\keystore'))

给我以下追溯 -

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\requests\api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL] PEM lib (_ssl.c:2580)

$ b $请求中的b

推荐答案

cert 用于客户端站点证书icates,而不是CA商店。使用 verify 参数指定CA文件,例如:

cert in requests is used for client site certificates, not for the CA store. Use the verify parameter to specify the CA file, e.g.:

requests.get('https://www.example.com', verify='/etc/ssl/certs/ca-certificates.crt')

这篇关于生成用于python请求获取PEM lib错误的证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆