在 Rails 应用程序中向 PostgreSQL 提供 SSL 证书

Provide SSL certificate to PostgreSQL in a Rails app

我在使用 Amazon RDS PostgreSQL 实例的 Elastic Beanstalk 上有一个 Rails 应用程序。

我希望 pg 使用 SSL 连接到此数据库。

/config/ca/rds.pem 关注 http://docs.aws.amazon.com/AmazonRDS/[...], I saved rds-combined-ca-bundle.pem,我的 database.yml 看起来像这样:

production:
  adapter: postgresql
  database: <%= ENV['DB_NAME'] %>
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  host: <%= ENV['DB_ADDRESS'] %>
  port: <%= ENV['DB_PORT'] %>
  sslmode: 'require'
  sslrootcert: 'config/ca/rds.pem'

但我不知道它是否真的在使用 SSL:我可以将 sslrootcert 路径更改为任何内容,而且我的应用程序仍在运行。我错过了什么?

在您的 database.yml 中,您必须使用 sslmode: 'verify-full' 而不是 sslmode: 'require' 才能根据 SSL 证书中的端点验证实例端点。这样使用证书。