Quick Diagnostics
Check SSL Status
Use the health endpoint to check SSL connection status:Validate Configuration
Check SSL configuration programmatically:Common Issues and Solutions
Issue 1: SSL Connection Failed
Error Message:- PostgreSQL server doesn’t have SSL enabled
- SSL mode mismatch between client and server
- Certificate files are missing or inaccessible
- Network/firewall blocking SSL connections
-
Verify PostgreSQL SSL is enabled:
-
Check PostgreSQL configuration:
-
Verify certificate files exist:
-
Check certificate permissions:
-
Test with psql:
Issue 2: Certificate Verification Failed
Error Message:- CA certificate doesn’t match server certificate
- Certificate has expired
- Certificate chain is incomplete
- Hostname mismatch (for verify-full mode)
-
Verify CA certificate path:
-
Check certificate expiration:
-
Verify certificate matches server:
-
Check certificate chain:
-
Try verify-ca mode (for testing):
-
Check hostname in certificate:
Issue 3: Connection Timeout with SSL
Error Message:- Network connectivity issues
- Firewall blocking SSL connections
- PostgreSQL not listening on SSL port
- SSL handshake failing
-
Test network connectivity:
-
Check firewall rules:
-
Verify PostgreSQL is listening:
-
Test SSL handshake:
-
Check PostgreSQL logs:
Issue 4: SSL Required but Not Available
Error Message:- PostgreSQL server doesn’t support SSL
- SSL mode is set to disable
- Connection falling back to non-SSL
-
Check SSL requirement setting:
-
Verify SSL mode:
-
Check PostgreSQL SSL support:
-
Temporarily allow fallback (for debugging):
Issue 5: Auto-Generation Failed
Error Message:- Certificate directory doesn’t exist
- Insufficient permissions
- Disk space full
- Certificate generation library missing
-
Check certificate directory:
-
Fix permissions:
-
Check disk space:
-
Verify cryptography library:
-
Manually generate certificates:
Issue 6: Client Certificate Issues (Mutual TLS)
Error Message:- Client certificate not provided
- Certificate and key mismatch
- Certificate not signed by CA
- Certificate expired
-
Verify both certificate and key are provided:
-
Check certificate and key match:
-
Verify certificate is signed by CA:
-
Check certificate expiration:
Debugging Commands
PostgreSQL SSL Status
Certificate Inspection
Connection Testing
Configuration Validation
Logging and Monitoring
Enable Debug Logging
Check Application Logs
Monitor SSL Health
Performance Issues
SSL Handshake Overhead
SSL adds minimal overhead (~1-2ms per connection). If experiencing performance issues:-
Use connection pooling:
- SSL connections are reused in the pool
- Reduces handshake overhead
-
Check connection pool settings:
-
Monitor connection times:
Getting Help
If you’re still experiencing issues:-
Collect diagnostic information:
-
Check application logs:
- Look for SSL-related error messages
- Check stack traces for connection failures
- Review documentation:
-
Contact support:
- Include diagnostic information
- Provide error messages and logs
- Describe steps to reproduce
Prevention
To avoid SSL issues:- Validate configuration before deployment
- Test SSL connections in staging first
- Monitor certificate expiration dates
- Use automated certificate rotation
- Regular health checks
- Keep certificates secure and backed up