Is SQLAlchemy/psycopg2 connection to PostgreSQL database encrypted

為{幸葍}努か 提交于 2020-01-04 01:57:08

问题


When I use SQLAlchemy with an external postgreSQL server, is the connection secured/encrypted?

from sqlalchemy.engine import create_engine engine = create_engine('postgresql://scott:tiger@ip:5432/mydatabase')

What about psycopg2?


回答1:


Your connection string does not indicate secure connection. However, sometimes connection might be secure nevertheless, but it is unlikely.

To have a secure connection to PostgreSQL database you can use sslmode parameter.

 engine = create_engine('postgresql://scott:tiger@ip:5432/mydatabase?sslmode=verify-full')

verify-full is the highest level SSL connection validation where the client performs full SSL certificate check for the connection.

More info:

  • https://www.postgresql.org/docs/current/static/libpq-ssl.html


来源:https://stackoverflow.com/questions/39813312/is-sqlalchemy-psycopg2-connection-to-postgresql-database-encrypted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!