无法在Postgres上启动GSSAPI安全上下文14逻辑复制

发布于 2025-01-28 13:30:11 字数 1348 浏览 3 评论 0原文

我正在关注此 post 复制。然后尝试在客户端上建立连接:

CREATE SUBSCRIPTION my-sub
CONNECTION 'host=my-domain.com dbname=my-db user=my-username password=xxxxxx'
PUBLICATION my-pub;

它引发错误:

2022-05-12 13:51:36.047 PDT [37340] ERROR:  could not connect to the publisher: connection to server at "my_domain.com" (xxx.xxx.xxx.141), port 5432 failed: could not initiate GSSAPI security context:  The operation or option is not available: Credential for asked mech-type mech not found in the credential handle
    connection to server at "my_domain.com" (xxx.xxx.xxx.141), port 5432 failed: FATAL:  connection requires a valid client certificate
    connection to server at "my-domain.com" (xxx.xxx.xxx.141), port 5432 failed: FATAL:  no pg_hba.conf entry for host "xxx.xxx.xxx.199", user "my-username", database "my-db", no encryption

在my-pub服务器上,将一行添加到pg_hba.conf

hostssl all             all             0.0.0.0/0               scram-sha-256 clientcert=verify-full
 

在子客户端上,CA文件的设置如下:

ssl_ca_file = '/usr/local/var/postgres/root.crt'. //<<==client cert copied from pub server. 

I am following this post to enable ssl on Postgres 14 for logical replication. Then try to make connection on client:

CREATE SUBSCRIPTION my-sub
CONNECTION 'host=my-domain.com dbname=my-db user=my-username password=xxxxxx'
PUBLICATION my-pub;

It throws error:

2022-05-12 13:51:36.047 PDT [37340] ERROR:  could not connect to the publisher: connection to server at "my_domain.com" (xxx.xxx.xxx.141), port 5432 failed: could not initiate GSSAPI security context:  The operation or option is not available: Credential for asked mech-type mech not found in the credential handle
    connection to server at "my_domain.com" (xxx.xxx.xxx.141), port 5432 failed: FATAL:  connection requires a valid client certificate
    connection to server at "my-domain.com" (xxx.xxx.xxx.141), port 5432 failed: FATAL:  no pg_hba.conf entry for host "xxx.xxx.xxx.199", user "my-username", database "my-db", no encryption

On my-pub server, one line was added to pg_hba.conf:

hostssl all             all             0.0.0.0/0               scram-sha-256 clientcert=verify-full
 

On sub client, the ca file is setup as below:

ssl_ca_file = '/usr/local/var/postgres/root.crt'. //<<==client cert copied from pub server. 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2025-02-04 13:30:11

人们通常只使用服务证书。我会说,使用客户证书是不寻常的,特别是在逻辑复制订户的情况下。但是,如果您确实希望发布者要求客户证书,则不会为此目的不正确地配置它(或者至少不是我们可以从当前数据中分辨出来)。出版商要求客户证书,但订户没有提供。配置问题在订户上。

请注意,在这种情况下,订户将充当与发布者连接的客户,而不是在服务器的角色中起作用。它使用libpq client库来做到这一点,因此它的配置不是基于postgresql.conf的内容。特别是,SSL_CA_FILE是服务器配置选项,而不是客户端配置。

因此,这样做的方法是使连接看起来像是这样的,

'host=my-domain.com dbname=my-db user=my-username password=xxxxxx sslcert=/foobar/my-username.crt sslkey=/foobar/my-username.key'

但是要使这种连接起作用,证书和密钥需要在订户计算机上使用,这对于拥有Postgres Process的任何人都可以阅读。这已经使任何安全福利可疑。

Mostly people just use serve certs. Using client certs is unusual, I would say especially in the case of a logical replication subscriber. But if you do actually want the publisher to demand client certs, it is not configured incorrectly to that purpose (or at least, not that we can tell from the current data). The publisher is demanding a client cert, but the subscriber is not offering one. The configuration problem is on the subscriber.

Note that in this case the subscriber will be acting as the client to connect to the publisher, not acting in the role of a server. It uses the libpq client library to do that, and so the configuration of it is not based on the contents of postgresql.conf. In particular, ssl_ca_file is a server configuration option, not client configuration.

So the way to do this would be for the CONNECTION to look something like

'host=my-domain.com dbname=my-db user=my-username password=xxxxxx sslcert=/foobar/my-username.crt sslkey=/foobar/my-username.key'

But for this to work, the cert and key would need to be on the subscriber computer, readable to whomever owns the postgres process. Which already renders any security benefit dubious.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文