python-3.x - 使用 aiogremlin 连接到 Neptune
问题描述
我正在尝试使用aiogremlin连接到 AWS Neptune,但不断收到 SSL 证书错误。我尝试使用从Amazon Trust Repository下载的 3 个不同的证书,但它们都不起作用。随着AmazonRootCA1.pem
和SFSRootCAG2.pem
我不断得到File Not Found error
和SFSRootCAG2.cer
我得到ssl_context.load_cert_chain(ssl.SSLError: [SSL] PEM lib (_ssl.c:4046)
。
这是我用来与 Neptune 交互的片段。
import asyncio
from aiogremlin import DriverRemoteConnection, Graph
from .constants import NEPTUNE_ENDPOINT, CERT_DIR
async def go():
remote_connection = await DriverRemoteConnection.open(f'https://{NEPTUNE_ENDPOINT}:8182/gremlin', 'g',
ssl_certfile=CERT_DIR+'SFSRootCAG2.cer')
g = Graph().traversal().withRemote(remote_connection)
vertices = await g.V().toList()
await remote_connection.close()
return vertices
print(asyncio.get_event_loop().run_until_complete(go()))
无法确定我是否使用了错误的证书文件或做其他错误的事情。
解决方案
当我将密钥库转换为没有证书部分的 pem 文件时,我得到了完全相同的错误(直到 ssl.c 中的第 4046 行)。
我在没有'-nocerts'标志的情况下再次转换它,并且我在文件中得到了两个部分,如下所示:
Bag Attributes
friendlyName: mykey
localKeyID: ...
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
... [magic key details] ...
-----END PRIVATE KEY-----
Bag Attributes
friendlyName: mykey
localKeyID: ...
subject=C = NO, O = ..., CN = Server Administrator
issuer=C = NO, O = ..., CN = Server Administrator
-----BEGIN CERTIFICATE-----
... [magic key details] ...
-----END CERTIFICATE-----
我还创建了一个这样的新证书,它可以毫无问题地工作:
# openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
推荐阅读
- postgresql - PostgreSQL:pg_sleep 的串联
- python - 为什么 Python 在调用派生自 C++ std::vector 的 pybind11 type_cast-ed 类的方法时会抱怨?
- r - 如何一次性计算 R 中 group_by 变量的总数?
- vue.js - 只看一次触发 - vue3
- r - 从数据框中的特定行中删除括号内的文本
- django - 固定装置/加载数据中的 Django id vs pk
- ios - Apple 代码兑换 - presentCodeRedemptionSheet() 未提供任何反馈
- amazon-web-services - Terraform EKS 配置图被禁止
- python - 有效地将具有反向字典的文件读取到DataFrame
- git - 如何从远程仓库中提取特定提交