我正在關注這篇文章以在 Postgres 14 上啟用 ssl 以進行邏輯復制。然后嘗試在客戶端建立連接:
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.
uj5u.com熱心網友回復:
大多數人只使用服務證書。使用客戶端證書是不尋常的,尤其是在邏輯復制訂戶的情況下。但是,如果您確實希望發布者要求客戶端證書,那么它并沒有被錯誤地配置為該目的(或者至少,我們不能從當前資料中看出)。發布者要求客戶證書,但訂閱者不提供。配置問題出在訂戶上。
請注意,在這種情況下,訂閱者將充當連接到發布者的客戶端,而不是充當服務器的角色。它使用 libpq 客戶端庫來執行此操作,因此它的配置不是基于 postgresql.conf 的內容。特別是, ssl_ca_file 是一個服務器配置選項,而不是客戶端配置。
所以這樣做的方法是讓 CONNECTION 看起來像
'host=my-domain.com dbname=my-db user=my-username password=xxxxxx sslcert=/foobar/my-username.crt sslkey=/foobar/my-username.key'
但要使其作業,證書和密鑰需要在訂閱者計算機上,任何擁有 postgres 行程的人都可以讀取。這已經使任何安全利益變得可疑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/478588.html
標籤:PostgreSQL ssl 数据库复制
上一篇:TensorflowOD模型動物園的CenterNetMobileNetV2中的這兩個檔案是什么?,我們需要它們嗎?
