Excel2016: Cannot query PostgresSQL database: Server certificate not accepted

时间:2018-12-03 13:17:05

标签: excel postgresql certificate

I want to import some data to Excel2016 from a postgresSQL table. I have tried it by clicking "new query" and selecting From Database -> From PostgresSQL Database:

enter image description here

But then I receive the following error:

Details: "TlsClientStream.ClientAlertException: CertificateUnknown: Server certificate was not accepted. Chain status: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider. . The specified hostname was not present in the certificate. at TlsClientStream.TlsClientStream.ParseCertificateMessage(Byte[] buf, Int32& pos) at TlsClientStream.TlsClientStream.TraverseHandshakeMessages() at TlsClientStream.TlsClientStream.GetInitialHandshakeMessages(Boolean allowApplicationData) at TlsClientStream.TlsClientStream.PerformInitialHandshake(String hostName, X509CertificateCollection clientCertificates, RemoteCertificateValidationCallback remoteCertificateValidationCallback, Boolean checkCertificateRevocation)"

Any suggestions on how to solve this? Thank you so much in advance!

2 个答案:

答案 0 :(得分:1)

此错误表示正在建立与PostgreSQL db的连接,在此连接中客户端无法验证服务器的证书。仅当Excel用于连接到PostgreSQL(npgsql)的库中的“信任服务器证书”设置为FALSE时,才会发生此错误。

可以通过以下几种方式来解决此问题,按照我建议尝试的顺序:

  1. 如果Excel中隐藏了一个选项(可能位于高级选项或类似选项下),则将“信任服务器证书”参数设置为True,则您的连接将开始工作。如果允许您指定整个连接字符串,那么也可以在连接字符串中完成。

  2. 数据库应该在数据库的postgresql.conf文件中列出的SSL证书中具有公共密钥。如果您(或您的数据库管理员)可以获取该公钥并将其添加到您的计算机中(说明会因操作系统而异)。

答案 1 :(得分:0)

我终于找到了解决我问题的方法。 您可以做的是:

  1. here

  2. 安装当前的postgresql驱动程序
  3. 遵循此video

  4. 中的说明

这样,您可以通过ODBC连接到您的postgreSQL数据库。