簡體   English   中英

如何在 Windows 環境中使用 SSL 和 sslrootcert 參數連接到 AWS PostgreSQL RDS 實例?

[英]How do I connect to an AWS PostgreSQL RDS instance using SSL and the sslrootcert parameter from a Windows environment?

我們有一個Windows EC2實例,在該實例上運行自定義命令行應用程序(使用 NpgSQL 的 C# 控制台應用程序)以連接到 PostgreSQL RDS 實例。 根據此處的說明:

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL

我們創建了一個新的數據庫參數組,將rds.force_ssl set1並重新啟動了我們的 RDS 實例。 我們還將頁面上引用的 pem 文件下載並導入到 Windows。

通過將SSL mode as Verify-Full指定SSL mode as Verify-Full ,我能夠通過 pgAdmin 從我的 Windows EC2 實例連接到 RDS 實例。 我們的命令行應用程序從文件中讀取連接字符串,現在我添加了 sslmode 參數,它們看起來像這樣:

Server=OurInstanceAddress;Port=5432;SearchPath='$user,public,topology';Database=OurDatabase;User Id=username;Password=mypassword;sslmode=verify-full;

使用此連接字符串失敗,並顯示頁面底部引用的錯誤:

FATAL: no pg_hba.conf entry for host "host.ip", user "someuser", database "postgres", SSL off

我嘗試添加 sslrootcert 參數,但我不確定我是否正確處理它。 我嘗試使用示例 (sslrootcert=rds-ssl-ca-cert.pem) 並嘗試使用我下載的 pem 的名稱。 我覺得我提供給 sslrootcert 參數的路徑信息有些不對,尤其是在 Windows 環境中。 我試過使用名稱,我試過使用以下路徑:

- sslrootcert=C:\keys\rds-combined-ca-bundle.pem - single backslash
 - sslrootcert=C:\\\keys\\\rds-combined-ca-bundle.pem - double backslash
 - sslrootcert=C:/keys/rds-combined-ca-bundle.pem - Linux style backslash

所有這些都產生了上述相同的錯誤。

任何見解將不勝感激。

我使用環境變量解決了它,而不是在連接 url 中指定證書路徑

 -DPGSSLROOTCERT=/certs/root.crt 
 -DPGSSLKEY=/certs/amazon-postgresql.key 
 -PGSSLCERT=/certs/amazon-postgresql.crt

雖然我在cygwin。 在此處使用 Windows 時,文檔中有一些提示https://www.postgresql.org/docs/9.0/static/libpq-ssl.html

暫無
暫無

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

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