moosecles
moosecles

Reputation: 43

Why is my AWS RDS server giving me this "no encryption" error when connecting?

I am trying to learn how to use AWS RDS. I am running across this error when connecting:

Error invoking remote method 'DB_CONNECT': error: no pg_hba.conf entry for host "EXAMPLE IP HERE", user "EXAMPLE USER HERE", database "EXAMPLE DATABASE NAME HERE", no encryption.

This database is using the free tier and will be for my personal project.

I tried:

Upvotes: 4

Views: 5261

Answers (3)

Hassan Akhlaq
Hassan Akhlaq

Reputation: 445

I was trying to connect via pg8000 SQL Alchemy and this was the easiest one.. FYI, Adding this incase someone like me is stuck.

import ssl

ssl_context = ssl.create_default_context()
ssl_context.check_hostname=False
ssl_context.verify_mode = ssl.CERT_NONE
db.create_engine(f"postgresql+pg8000://{credentials['user']}:{credentials['password']}@{credentials['host']}:{credentials['port']}/{credentials['database']}", connect_args={'ssl_context': ssl_context})

Upvotes: 0

John Rotenstein
John Rotenstein

Reputation: 270134

As per Securing connections to RDS for PostgreSQL with SSL/TLS - Amazon Relational Database Service, it is recommended that you use Secure Socket Layer (SSL) encryption when connecting to the database.

The error message you are receiving indicates that your SQL client connection is not using SSL ("no encryption").

If you activate SSL for your connection, it should be able to connect.

Upvotes: 2

Ramesh Eega
Ramesh Eega

Reputation: 86

Based on error I am assuming you are running RDS Postgres. Are you trying to connect to the database over internet ( I believe so since you mentioned security group opened for 0.0.0.0/0)

Did you select Public access under connectivity ? Otherwise RDS Amazon RDS doesn't assign a public IP address to the database.

This may help you configure public access if needed https://repost.aws/knowledge-center/rds-connectivity-instance-subnet-vpc

If you had set rds.force_ssl to 1 in parameter group, you must connect using psql (for example) as below

psql -h $RDSHOST "user=xxx dbname= sslmode=require"

Upvotes: 2

Related Questions