简体   繁体   English

postgresql 中 SSL 连接上的“主机名未验证错误消息”

[英]“HostName not verified error message” on SSL connection in postgresql

I created server.crt , server.key and root.crt files on Centos 7 and put the same onto the C:\\Users\\xxxx\\AppData\\Roaming\\postgresql folder in windows as i am running the postgresql server on windows.我在 Centos 7 上创建了server.crtserver.keyroot.crt文件,并将它们放在root.crtC:\\Users\\xxxx\\AppData\\Roaming\\postgresql文件夹中,因为我正在 Windows 上运行 postgresql 服务器。 Now on running my applications using SSL, i am getting the error as现在使用 SSL 运行我的应用程序,我收到错误

"The host name could not be verified" “无法验证主机名”

Any help please.请任何帮助。

I am using JetBrains Data Grip to access Postgres dbs on Heroku, and got the same error in the latest JDBC driver version.我正在使用 JetBrains Data Grip 访问 Heroku 上的 Postgres dbs,并在最新的 JDBC 驱动程序版本中遇到相同的错误。 That's how I solved it (using answers provided here).这就是我解决它的方法(使用此处提供的答案)。

Set the following in the Advanced tab:在高级选项卡中设置以下内容:

ssl=true ssl=真

sslmode=require sslmode=需要

sslfactory=org.postgresql.ssl.NonValidatingFactory sslfactory=org.postgresql.ssl.NonValidatingFactory

(I updated sslmode value from verify-ca to required because it works with Heroku Postgres now) (我将sslmode值从verify-ca更新为required因为它现在可以与 Heroku Postgres 一起使用)

如果您不关心主机名验证但仍想使用证书,则可以使用附加参数sslmode=verify-ca作为连接参数或作为 URL 的一部分来禁用主机名验证,同时保留证书验证。

To use the PostgreSQL JDBC driver without server certificate validation, use要在没有服务器证书验证的情况下使用 PostgreSQL JDBC 驱动程序,请使用

sslfactory=org.postgresql.ssl.NonValidatingFactory

as connection parameter or as part of the URL as described in the documentation .作为连接参数或作为文档中描述的 URL 的一部分。

With later versions of the JDBC driver, you have to specify对于更高版本的 JDBC 驱动程序,您必须指定

sslmode=require

because the default value verify-full means that the client wants to check the certificate and identity of the server.因为默认值verify-full意味着客户端要检查服务器的证书和身份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM