Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support sslrootcert=system #3101

Open
cassus opened this issue Nov 25, 2023 · 2 comments
Open

support sslrootcert=system #3101

cassus opened this issue Nov 25, 2023 · 2 comments

Comments

@cassus
Copy link

cassus commented Nov 25, 2023

From v16 the postgres client supports a special sslrootcert connection string param that uses the system root certificate storage. It would be great if node-postgres would also support this param

The special value system may be specified instead, in which case the system's trusted CA roots will be loaded. The exact locations of these root certificates differ by SSL implementation and platform. For OpenSSL in particular, the locations may be further modified by the SSL_CERT_DIR and SSL_CERT_FILE environment variables.

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT

Current behavior

when sslrootcert=system is in the connection string the behavior is TypeError: dr.readFileSync is not a function

sslrootcert=system is already the default behavior of node-postgres, but it's not obvious for me by reading the https://node-postgres.com/features/ssl documentation

Blog post:

I’m pleased to report that the node-postgres TLS implementation defaults to sslrootcert=system behavior unless you explicitly specify the option rejectUnauthorized=false.
https://neon.tech/blog/avoid-mitm-attacks-with-psql-postgres-16

@charmander
Copy link
Collaborator

sslrootcert=system might already be the default behavior of node-postgres

(it is)

@cassus
Copy link
Author

cassus commented Nov 26, 2023

Great! Thanks @charmander!
I updated the issue description.

I guess this means that the implementation of this feature would be very easy: just ignore sslrootcert if it's set to system ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants