找不到 root.crt postgresql

Pra*_*aga 6 linux docker postgresql-10

我有一个我正在使用的 postgres docker 映像,并且我正在其上启用 SSL。我希望它验证完整,因为我有一个 root.crt 并且想要确保所有可以使用 SSL 的证书都经过验证。因此,在我的 docker-compose 文件中,我已将 server.crt 和 server.key 挂载到 /var/ssl,将 root.crt 挂载到 /root/.postgresql。

卷: - ~/server_certs:/var/ssl - ~/root_certs:/root/.postgresql

我得到的错误是

ERROR [2018-07-10 20:28:24,355] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! java.io.FileNotFoundException: /root/.postgresql/root.crt (No such file or directory)
! at java.io.FileInputStream.open0(Native Method)
! at java.io.FileInputStream.open(FileInputStream.java:195)
! at java.io.FileInputStream.<init>(FileInputStream.java:138)
! at java.io.FileInputStream.<init>(FileInputStream.java:93)
! at org.postgresql.ssl.jdbc4.LibPQFactory.<init>(LibPQFactory.java:124)
! ... 32 common frames omitted
! Causing: org.postgresql.util.PSQLException: Could not open SSL root certificate file /root/.postgresql/root.crt.
Run Code Online (Sandbox Code Playgroud)

任何有关让 postgres 找到 root.crt 的帮助将不胜感激(postgres 10 btw)

小智 10

作为一种解决方法,您可以将sslmode=require(无证书验证!)或sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory(使用 JRE 信任库验证证书)添加到您的 JDBC url。

这种行为和提到的解决方法在https://github.com/pgjdbc/pgjdbc/issues/1307 中有描述