-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[BUG] Inputs PostgreSQL plugin will not work with CA cert validation #9134
Comments
Hi, So I've found a few things which I think might be related/helpful: There is an open issue on jackc/pgx with someone getting the same error message as you. It may be worth commenting on this thread to see if this is something that would be fixed if we upgraded to jackc/pgx v4 (we are currently using v3.6.0). In these postgreSQL docs it references using sslmode=require instead of verify-ca for older versions of postgreSQL. What version of postgreSQL are you using? It looks from the source code of jackc/pgx that in either case of setting verify-full or verify-ca it's setting the serverName to the host name whereas in the case of require it sets insecure skip verify to true. Which may be the reason why setting it to require is fixing this for you. Are you willing to reach out on that issue to see if this is something that would change if we upgraded? Otherwise I think we may need to update the readme to explain this behavior. |
Hi @helenosheaa , thank you for your answer.
I think the creator of the issue is using an old version of pgx.
We use PostgreSQL version 11.
I think that will be the problem :)
I had a closer look at the pgx code and found the following issues:
I think an update to V4 (at least 4.6.0) should solve the problem. Should I prepare a PR? Many greetings Pascal |
Hi @ZPascal, Thanks for looking into that and showing what you found! If you could prepare a PR that would be great. It seems like V4.0.6 will solve the problem so upgrading will make sense. Feel free to @ me on the PR when it comes in so I can review. |
Hi @helenosheaa , I have finished the PR so far. I will now run the integration tests and fix them if necessary. FYI: However, I noticed another error in my upper post. I had written about version 4.0.6, but linked v4.6.0. The current error is fixed since version 4.6.0 of pgx. |
Relevant telegraf.conf:
System info:
Docker
Dockerfile
Steps to reproduce:
Expected behavior:
I expect the establishment of an encrypted connection to the database and smooth functionality of the PostgreSQL plugin.
Actual behavior:
We have configured an encrypted connection to the PostgreSQL database including CA-Cert validation in our Telegraf configuration. After starting Telegraf, the following error is displayed in the error log and no connection to the database can be established.
[inputs.postgresql] Error in plugin: x509: cannot validate certificate for 192.168.0.10 because it doesn't contain any IP SANs
Additional info:
Of course, we have already checked the certificate and established a connection to the DB using the psql client. There were no problems and the encrypted connection could be established without problems in
verify-ca
mode. Our CA certificate does not have a SAN entry, but in my opinion this entry should be checked in verify-full mode.I have the feeling that the database driver interprets the rules wrong and uses verify-full instead of verify-ca.
Workaround:
As a workaround we changed the ssl mode to
require
and were able to connect to the database.The text was updated successfully, but these errors were encountered: