提问人:sorin182004 提问时间:7/29/2023 最后编辑:sorin182004 更新时间:7/29/2023 访问量:210
连接到 Amazon RDS 数据库时出现 pg-node 错误
pg-node error when connecting to amazon rds database
问:
我使用 Amazon RDS 控制台创建了一个数据库实例,为其分配了以下 VPC 安全组,授权任何 IPV4 地址连接到数据库(我知道这是不好的做法,但我迫切希望找到解决方案):
我还想指出,这场比赛!VPC security groups
我想使用库连接到此数据库:https://node-postgres.com,但我不断收到一个错误,上面写着:pg
error: no pg_hba.conf entry for host "**.***.***.**" (my IP), user "postgres", database "desk_booking", no encryption
at Parser.parseErrorMessage (C:\apps\itec2022\node_modules\pg-protocol\src\parser.ts:369:69)
at Parser.handlePacket (C:\apps\itec2022\node_modules\pg-protocol\src\parser.ts:188:21)
at Parser.parse (C:\apps\itec2022\node_modules\pg-protocol\src\parser.ts:103:30)
at Socket.<anonymous> (C:\apps\itec2022\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Socket.Readable.push (node:internal/streams/readable:234:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 165,
severity: 'FATAL',
code: '28000',
detail: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '543',
routine: 'ClientAuthentication'
}
我读到无法更改通过 RDS 控制台创建的数据库。pg_hba.conf
当我尝试使用完全相同的凭据连接到数据库时,它起作用了:psql
我知道有一种方法可以绕过这个问题,通过设置
ssl: {
rejectUnauthorized: false,
}
但我觉得这很笨拙,不是最佳实践(尽管我不确定,因为它也用于官方 node-postgres 文档:https://node-postgres.com/features/ssl)。我想知道此选项是否可以在具有 Amazon RDS 的生产环境中使用。它会带来任何安全问题吗?与 、 参数结合使用是否更安全(如下所述:https://node-postgres.com/features/ssl)?如果是这样,我如何获取这些值?ca
key
cert
我也试过:
ssl: true
这会导致以下错误:
Error: self-signed certificate in certificate chain
at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34)
at TLSSocket.emit (node:events:513:28)
at TLSSocket.emit (node:domain:489:12)
at TLSSocket._finishInit (node:_tls_wrap:959:8)
at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:743:12) {
code: 'SELF_SIGNED_CERT_IN_CHAIN'
}
我想知道为什么允许访问终端,而我的申请被拒绝。此外,我该如何解决这个问题?
答: 暂无答案
评论
rds.force_ssl = true