简体   繁体   中英

SSL connection in Play! Framework

From the Play! API it follows that a database connection can be made with the following configs in application.conf:

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://someDomain.com/someDatabase"
db.default.user=user
db.default.password=password

But when I'm throwing in &ssl=true in the url, it doesn't get registered and I receive the following error:

Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "xx.xx.xx.xx", user "user", database "test&ssl=true&sslfactory=org.postgresql.ssl.NonValida", SSL off

Are there any ways you can force Play! to use SSL connections through the .conf file?

Update: I forgot to mention that I made a successful login attempt from a console using the psql command. Somehow it must be Play that doesn't understand the ssl parameter.

Thanks,

Postgresql reporting database "test&ssl=true&sslfactory=org.postgresql.ssl.NonValida" as the database name you're trying to connect to indicates that the JDBC driver isn't taking that suffix off the end and handling it, as you need it to do.

You probably need to use ? before the first parameter, like a normal URL:

jdbc://db.example.com/test?ssl=true

The problem appears to be configuration on the Postgres end?

From the docs I suspect the default pg_hba.conf file being created by the db doesn't contain an entry for SSL and you need to add this manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM