In late 2012, things seem to have changed. Although documentation is still sparse, the pg gem seems to auto-negotiate SSL, and the jdbc drivers can be coerced to use SSL.
My app is a hybrid MRI-jRuby app, that accesses heroku-postgres, a cloud postgresql server that requires SSL.
# Gemfile.lock
pg (0.14.1)
activerecord-jdbc-adapter (1.2.2.1)
activerecord-jdbcpostgresql-adapter (1.2.2.1)
jdbc-postgres (9.1.901)
The pg gem, seemed to auto-negotiate SSL. However, the JDBC adapter did not. MRI connected with a typical database.yml (no mention of ssl), but JDBC threw:
(FATAL: no pg_hba.conf entry for host "xx.xx.xx.xx", user "username", database "database", SSL off)
I eventually tried specifying the connection details in JDBC-URL format, and the connection succeeded:
# jruby database.yml
production:
adapter: jdbcpostgresql
url: jdbc:postgresql://host/database?user=user&password=password&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
(sslfactory may not be needed for all setups)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…