我使用python在Heroku postgresql中使用asyncpg连接我的数据库:
import asyncpg
async def create_db_pool():
bot.pg_con = await asyncpg.create_pool(dsn="postgres://....", host="....amazonaws.com", user="xxx", database="yyy", port="5432", password="12345")它一直工作得很好,直到我收到一封来自heroku的电子邮件,建议我进行维护:
Maintenance (DATABASE_URL on myappname) is starting now. We will update you when it has completed.
然后出现这个错误:
asyncpg.exceptions.InvalidAuthorizationSpecificationError: no pg_hba.conf entry for host "123.456.789.10", user "xxx", database "yyy", SSL off我试着遵循一些帮助,比如放入ssl=True,但出现了这个错误:
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1108)与putting ssl="allow"相同
asyncpg.exceptions.InvalidPasswordError: password authentication failed for user "xxx"我能做些什么来解决这个问题呢?
发布于 2021-03-16 14:33:54
使用this的解决方案成功了。
import ssl
ssl_object = ssl.create_default_context()
ssl_object.check_hostname = False
ssl_object.verify_mode = ssl.CERT_NONE
# connect elsewhere
pool = await asyncpg.create_pool(uri, ssl=ssl_object)注意:您不需要使用评论中提到的任何证书,因为我们将verify_mode设置为不使用证书。
https://stackoverflow.com/questions/62053185
复制相似问题