- Newest
- Most votes
- Most comments
The "unexpected eof while reading" error you're encountering suggests that the SSL handshake is not completing successfully. This could be due to several reasons:
-
Security Group Configuration: The most common cause of connection issues is incorrect security group settings. Ensure that your RDS instance's security group allows inbound traffic on port 5432 from your client's IP address.
-
SSL/TLS Version Mismatch: Your RDS PostgreSQL instance might be configured to use a specific SSL/TLS version that's incompatible with the version OpenSSL is attempting to use. RDS for PostgreSQL supports TLS versions 1.1, 1.2, and 1.3.
-
Certificate Issues: Verify that you're using the correct and up-to-date CA certificate. AWS periodically updates their certificates, and using an expired or incorrect certificate can cause connection failures.
-
RDS Configuration: Check if SSL is enforced on your RDS instance. The
rds.force_sslparameter, when set to 1, requires SSL for all connections.
To troubleshoot this issue:
-
Verify Security Group: Review your RDS instance's security group and ensure it allows inbound connections from your client's IP address on port 5432.
-
Check SSL Enforcement: Connect to your RDS instance and check if
rds.force_sslis set to 1. If it is, ensure you're using the correct SSL configuration in your connection attempt. -
Update CA Certificate: Download the latest CA certificate from AWS and ensure you're using it in your OpenSSL command.
-
Try Different TLS Versions: Modify your OpenSSL command to explicitly specify TLS versions, e.g., add
-tls1_2to force TLS 1.2. -
Check RDS Logs: Review the PostgreSQL logs in Amazon RDS to see if there are any error messages related to SSL connections.
-
Test with psql: Try connecting using the psql client with SSL to isolate whether the issue is specific to OpenSSL or a general SSL connection problem.
If the issue persists after trying these steps, you may need to contact AWS support for further assistance, as there could be a configuration issue with your RDS instance that's not immediately apparent.
Sources
Troubleshooting connections to your RDS for PostgreSQL instance - Amazon Relational Database Service
Using SSL with a PostgreSQL DB instance - Amazon Relational Database Service
Troubleshoot Amazon RDS expired SSL/TLS certificate connection issues | AWS re:Post
