确实轨Postgres的适配器都支持SSL? [英] does rails postgres adapter support ssl?

查看:340
本文介绍了确实轨Postgres的适配器都支持SSL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图配置一个Rails应用程序远程连接到一个Postgres数据库。我注意到,对于MySQL的连接适配器有指定用于建立一个SSL连接时所需的信息选项,但在为Postgres / PG适配器没有相应的选项。

i'm trying to configure a rails app to remotely connect to a postgres db. i've noticed that the connection adapters for mysql have options that specify the required info for setting up an ssl connection, but there is no equivalent options for the postgres/pg adapter.

谷歌搜索周围后,我一直没能找到任何或者(仅通过ssh隧道连接)。

after googling around, i haven't been able to find anything either (only connecting via an ssh tunnel).

这么简单,是试图让铁轨Postgres的适配器连接通过SSL穷途末路?

so simply, is trying to get the rails postgres adapter to connect over ssl a dead end?

感谢。任何帮助或方向AP preciated。

thanks. any help or direction is appreciated.

-h

推荐答案

在2012年年底,事情似乎发生了变化。尽管文件仍然稀疏,在PG宝石似乎自动协商SSL,并且JDBC驱动程序可以强制使用SSL。

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.

我的应用程序是一个混合的MRI JRuby应用程序,访问的Heroku,Postgres的,要求SSL云PostgreSQL服务器。

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)

在PG宝石,似乎自动协商SSL。然而,JDBC适配器没有。 MRI具有典型的database.yml(没有提及的SSL)连接,而JDBC扔:

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)

我终于尝试了指定的JDBC-URL格式的连接的详细信息,并连接成功:

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可能不需要为所有设置)

(sslfactory may not be needed for all setups)

这篇关于确实轨Postgres的适配器都支持SSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆