postgresql - 如何从本地使用 SSL 加密连接到 AWS RDS?
问题描述
我想通过本地的 EC2 连接到 AWS RDS。
我在本地机器上创建了一个隧道:
ssh -i ~/.ssh/id_rsa -f -N -L 5432:RDS-Endpoint:5432 EC2-User@EC2-IP -v
这种方式可以工作:
psql -hlocalhost -Upostgres -p5432 -d postgres
它真正连接到 RDS 数据库。
但是如果使用另一个具有 SSL 证书的 postgres 用户
psql -hlocalhost -p5432 "sslmode=verify-full sslrootcert=rds-ca-2019-root.pem user=another_user dbname=my_db"
导致此错误:
psql: error: server certificate for "tf-xxx.rds.amazonaws.com" (and 2 other names) does not match host name "localhost"
如果在 EC2 服务器上执行此操作,则效果很好。在本地,证书似乎不匹配localhost
。那么如何正确设置呢?
解决方案
在 PostgreSQL 中使用 SSL 加密sslmode=verify-full
与使用 SSL 隧道是互斥的,因为端点实际上是“中间人”。
推荐阅读
- python - Python:实例方法在被自身调用时返回“none”
- kotlin - Kotlin:“折叠”函数如何接受一个参数?
- encryption - 多次转发的视频如何在数据库中存储为单个副本?
- spring - Spring Boot jpa 防止自动更新
- html - Laravel 单选按钮未选中
- jmeter - 在 Jmeter 中生成 Html 报告失败
- c# - 此平台不支持从 powershell 创建 NHibernate 配置的操作
- c# - 防止 Web API 2 输入上的 Sql 注入
- javascript - 如何将值从子功能组件传递给父类组件?
- c# - 返回的 Windows 10 屏幕尺寸始终为 1024x768