无法使用SSL与Postgr建立Springboot连接

发布于 2025-02-07 18:33:06 字数 681 浏览 1 评论 0原文

使用SSL与Postgres进行连接时会引发异常。

引起的:javax.net.ssl.sslexception:收到致命警报: attrifter_message在 sun.security.ssl.alerts.getsslexception(alters.java:208)at sun.security.ssl.alerts.getsslexception(alters.java:154) sun.security.ssl.sslsocketimpl.recvalert(sslsocketimpl.java:2020)at sun.security.ssl.sslsocketimpl.readRecord(sslsocketimpl.java:1127) sun.security.ssl.sslsocketimpl.permenitialhandshake(sslsocketimpl.java:1367) 在 sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1395) 在 sun.security.ssl.sslsocketimpl.starthandshake(sslsocketimpl.java:1379) 在org.postgresql.ssl.makessl.convert(makessl.java:41)... 57常见 忽略框架

Exception is thrown while making connection to Postgres using SSL.

Caused by: javax.net.ssl.SSLException: Received fatal alert:
unexpected_message at
sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at
sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at
sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2020) at
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1127) at
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:41) ... 57 common
frames omitted

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

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

发布评论

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

评论(2

相思故 2025-02-14 18:33:06

尝试更改连接的驱动程序设置,以包括“ SSLMode”参数并将其设置为“ require”。

您可能还需要添加一个“ sslrootcert”参数,将其设置为本地计算机上root CA证书的完整文件路径。

对于Springboot连接,通常意味着将其指定为与数据库URI的在线指定(在Application..properties等)中,即将上述附加到连接URI上的IE:

jdbc:postgresql://<host>:<port>/<dbname>?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory

Try changing the connection's driver settings to include the 'sslmode' parameter and setting it to 'require'.

You may also need to add a 'sslrootcert' parameter, setting it to the full file path of the root CA certificate on your local machine.

For a SpringBoot connection, this usually means specifying these as in-line with the database URI wherever you have it (in application.properties, etc.), i.e. appending the above to the connection URI as such:

jdbc:postgresql://<host>:<port>/<dbname>?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory
熊抱啵儿 2025-02-14 18:33:06

我能够解决我的问题。我们需要将SSLKEY转换为.pk8格式。

连接字符串:

jdbc:postgresql://<host>:<port>/<db>?currentSchema=public&ssl=true&sslmode=verify-full&sslcert=<path>/server.crt&sslkey=<path>/server.pk8&sslrootcert=<path>/ca.crt

Where <path> refers to certs location.

I was able to fix my problem. We need to convert sslkey to .pk8 format properly.

Connection string:

jdbc:postgresql://<host>:<port>/<db>?currentSchema=public&ssl=true&sslmode=verify-full&sslcert=<path>/server.crt&sslkey=<path>/server.pk8&sslrootcert=<path>/ca.crt

Where <path> refers to certs location.

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