簡體   English   中英

使用SSL連接到postgresql國外服務器出錯

[英]Error connecting to postgresql foreign server using SSL

我在使用 SSL 連接到使用 postgres_fdw 的外部服務器時遇到問題。 我在不同的服務器上工作,但似乎相同的過程在我的新機器上不起作用。

我主要遵循與此Percona 博客相同的步驟,並使用以下命令創建我的服務器:

create
    server my_fdw
    foreign data wrapper postgres_fdw
    options (
        host 'localhost',
        port '5432',
        dbname 'my_foreign_db',
        use_remote_estimate 'on',
        sslrootcert '/home/myhome/.postgresql/root.crt',
        sslcert '/home/myhome/.postgresql/postgresql.crt',
        sslkey '/home/myhome/.postgresql/postgresql.key',
        sslmode 'verify-full'
    )
;

grant usage on foreign server my_fdw to myuser;

create user mapping
    for myuser
    server my_fdw
    options (password_required 'false')
;

我使用 SSL 連接到主數據庫沒問題。但是,當我嘗試訪問外部服務器時,例如:

import 
    foreign schema foreign_schema
    from server my_fdw
    into local_schema
;

我收到以下錯誤:

ERROR:  could not connect to server "my_fdw"
DETAIL:  connection to server at "localhost" (::1), port 5432 failed: could not read root certificate file "/home/myhome/.postgresql/root.crt": Permission denied

root.crt文件歸myhome用戶所有,權限設置為 0600。我可以(暫時)將root.crt文件的權限更改為更寬松的權限,這將繞過此特定錯誤,但隨后我將獲得其他文件的錯誤相同。 但是,更改這些文件的權限將導致 postgres 失敗,因為它們必須是0600或更低。

似乎 postgres 在執行與外部服務器相關的命令時試圖以不同的操作系統用戶身份訪問 SSL 文件。 關於正在發生的事情或如何解決問題的任何想法?

當然,它使用的是不同的用戶——擁有數據庫服務器進程的用戶。 這通常是“postgres”。 您可能需要制作這些文件的副本,並對副本執行chown

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM