Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Unable to connect to remote Postgres DB with ssl=true #2394

Closed
warrenday opened this issue May 10, 2018 · 10 comments
Closed

Unable to connect to remote Postgres DB with ssl=true #2394

warrenday opened this issue May 10, 2018 · 10 comments

Comments

@warrenday
Copy link

Bug Report

Prisma Version 1.8

Issue
It is not currently possible to connect to a remote PostgresDB with ssl=true the option is either ignored or not supported.

Reproduction

run > prisma init
options:

  1. Use existing database
  2. PostgreSQL
  3. No

Enter connection details for remote database.

CLI throws error:
Could not connect to database. no pg_hba.conf entry for host "86.128.185.193", user "wctuojjcmucvxh", database "d3bjoonnf7l2sq", SSL off

Expected behavior?
The CLI should connect to the remote database

@andrewjmead
Copy link

andrewjmead commented May 21, 2018

Yup. I was having trouble connecting to an external database from pretty much any database hosting provider (AWS, Heroku, etc).

@andrewjmead
Copy link

Thanks! I was able to test the alpha channel (1.10.0-alpha.24) against the latest stable version (1.8.3).

When running prisma init on the alpha channel, I was asked if I wanted to use ssl. I said I did, and it confirmed my choice. The command finished successfully which is a step in the right direction. On 1.8.3, I wasn't even able to complete prisma init without getting the same error as @warrenday above.

I was expecting that deciding to use SSL would have some impact on the resulting docker-compose.yml file, but it did not appear so. I was still getting the same issue after running docker-compose up -d followed by prisma deploy.

prisma deploy spit out it's generic failure message. In the docker logs I got the original error:

Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "98.114.12.243", user "hwouamssimxewe", database "doj9s0n5ddpli", SSL off

While prisma init seems to be able to temporarily connect to the SSL database, it doesn't seem to preserve the SSL choice in any of the files it generates.

I also wasn't able to get past this issue when trying to manually enable ssl by changing the docker-compose.yml file that was generated.

@marktani
Copy link
Contributor

marktani commented Jun 5, 2018

Thanks a lot for the update, @andrewjmead! We'll soon double check if any changes to docker-compose.yml need to be made, or if there is another step that needs to be taken here.

@divyenduz
Copy link
Contributor

Reopening this because at the moment there is no documented way to pass the ssl value to prisma docker service.

While the CLI asks for ssl during prisma init, that information is not used by the service.

@divyenduz divyenduz reopened this Jun 6, 2018
@andrewjmead
Copy link

Yeah. I appears the new prisma init connects to the database just fine over SSL without a cert. It would be nice to see the same behavior carried over to the service.

@divyenduz
Copy link
Contributor

We are working on this issue from the backend perspective: #2594

This is not released yet but will be soon.

We will update this issue with instructions and close it then. Thanks!

@andrewjmead
Copy link

andrewjmead commented Jun 8, 2018

That's awesome. It looks like that would work great with SSL without certs.

Thanks for this.

cmcinroy pushed a commit to cmcinroy/prisma that referenced this issue Jun 11, 2018
@divyenduz
Copy link
Contributor

  1. CLI version > 1.10.1 - npm install -g prisma
  2. Prisma server version > 1.10
  3. ssl: true in DB options in docker-compose.yml file.

I can confirm that this is resolved.

@andrewjmead
Copy link

Yup! This is working for me too 😄

@Jhony0311
Copy link

Confirming is working on my end too 👍

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

No branches or pull requests

7 participants