Fix: Handle self-signed certificates in PostgreSQL SSL connections #1121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Handle self-signed certificates in PostgreSQL SSL connections
Problem
When connecting to PostgreSQL databases with SSL enabled (particularly AWS RDS instances), the MCP server fails with the error:
This issue occurs because AWS RDS uses SSL certificates that may not be in the default trusted certificate store, and the node-postgres library fails to validate the certificate chain.
Solution
This PR implements a flexible solution for handling SSL connections in the PostgreSQL MCP server:
Conditional SSL Configuration: SSL settings are only applied when needed, based on the connection string parameters (
sslmode=require
,prefer
,verify-ca
, orverify-full
).Configurable Certificate Validation: Added support for the
rejectUnauthorized
parameter in the connection string to control certificate validation:rejectUnauthorized=false
: Disables certificate validation (needed for AWS RDS with self-signed certs)rejectUnauthorized=true
: Enforces certificate validation (default for security)Improved Client Connections: Individual client connections now properly inherit SSL settings from the connection string.
Usage Examples
Related Issues
Fixes #1047