-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
SSL for Postgres #2000
Comments
Found this one actually - https://discuss.redash.io/t/using-heroku-postgres-as-datasource-how-to-force-sslmode-require/271/4 |
When you add a new Postgres Data Source, there should be an additional option to allow the user to enter additional connection parameters. My use case: I need to create multiple Data Sources to different PostgreSQL databases, all of which require SSL. I have different client certificates and keys for each of those databases. However, I have no way to tell Redash where the client certificate and key required for a particular database lives. This usually is handled in the Postgres connection string, which parses More info here: For reference, here's the Metabase panel for adding a new database, which allows for the specification of additional connection parameters. |
@kravets-levko I hacked this into my deployment and it works. Maybe this can help you. Here's what I did: In
In the same file, on line 134, I modified the definition of
I now can create Data Sources to each of my PostgreSQL databases that require SSL and specify the location of the certificate. The new Data Source form for PostgreSQL now looks like: |
thanks @clayheaton! @arikfr, WDYT about this? looks like a good solution |
There's one more issue that comes up... Google just announced that Postgres for Cloud SQL is out of beta. To use SSL with Cloud SQL, you generate a certificate on the VM in Google Cloud Console. It's a self-signed certificate, but they provide the server root certificate. You can use SSL Mode of To specify the location of the root certificate, I added:
According to 32.18.1. Client Verification of Server Certificates in the Postgres documentation:
In the VM where I'm running Redash, I can invoke However, when Redash is running (with The odd thing here is that I can set up the Data Source using the information and it tests correctly. It is only when I try to run a query that the error appears. This is from the logs:
Hence, I'm trying to figure out how to guarantee that Redash and psycopg2 are respecting the Basically, it appears that the logic used when testing a new Data Source connection is not the same as the logic used when creating a connection to execute a query. Somewhere along the line, the |
I think what I'm running into is this bug, at least on the Google Compute Environment Image that Redash makes available and/or the Google Cloud SQL databases to which I'm trying to connect: Somewhere, Postgres is compiled with an old version of OpenSSL that isn't properly handling the certificates. |
Thanks, @clayheaton for looking into this and providing the detailed feedback!
How did you setup your Redash instance? Using the GCE image?
While this is an easy fix, we prefer not to use file paths, but to rather store the certificate itself (like we do for BigQuery service account JSON file for example). This ensures that the Redash server is stateless and can be scaled, if needed. If psycopg2/libpq doesn't support accepting a certificate instead of a path, we can store it to a temporary location before usage. |
Hi @arikfr. Yes, I used the GCE Image to start and then upgraded Redash (from 2.0, I believe) and Ubuntu to be current. That image could stand to be updated at some point. I think the SSL issue I'm having may be related to the build of Postgres that Google Cloud SQL is using. I'm unaware of psycopg2/libpq supporting accepting a certificate instead of a path. However, I'm not a libpq expert, so I very possibly could be incorrect. I agree that your suggested approach is better. For my current needs, I have to get something working ASAP, so I'll stick with my hack until I'm either able to suggest a better improvement or your team commits a change in line with your suggestion. (The work I'm doing is related to helping my company prepare for the GDPR, so I'm sure you can understand the frenzy.) |
FYI, I stood up a new Postgres database on Google Cloud SQL and migrated my data to it. Redash now can connect via SSL with the hacky method that I posted above, likely because Google now is building Postgres on this instances without the bug I mentioned above. |
@clayheaton I ran into the same issue -- I needed to restart my local redash instance for the SSL cert changes to take effect properly. It seems the settings are not correctly propagated to db connection objects upon save, only upon restart. I think it's a broader issue than just I've submitted a PR that adds the various SSL parameters (#3259). @kravets-levko @arikfr thoughts? |
Implemented in #4871. |
Hi,
we use a lot of postgres databases and we have some servers in different points of the world. This means some of them would be used over public connections, meaning we are reluctant to setup our datasource to postgres without SSL.
However, it seems redash doesn't support it (yet) for Postgres.
Is it possible to have this enabled somehow? Or added to the roadmap?
The text was updated successfully, but these errors were encountered: