Excel2016 : Cannot query PostgresSQL database: Server certificate not accepted

标签 excel postgresql certificate

我想将一些数据从 postgresSQL 表导入到 Excel2016。我通过单击“新查询”并选择“从数据库”->“从 PostgresSQL 数据库”来尝试:

enter image description here

但随后我收到以下错误:

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)"

关于如何解决这个问题有什么建议吗?非常感谢您!

最佳答案

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

有几种方法可以解决这个问题,按照我建议的顺序尝试:

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

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

关于Excel2016 : Cannot query PostgresSQL database: Server certificate not accepted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53594679/

相关文章:

c# - 在 EPPlus 上设置行高时的奇怪行为

ios - Apple Pay 支付证书不受信任

java - 未找到证书链,但 keystore 包含私钥

c# - 连接到安全 WebService

c# - Dapper 和 Npgsql 通过使用带有 IN 子句和 List<int> 的 EXPLAIN 抛出异常

vba userform ,如果框架中的任何复选框为真,则不应将宏应用于复选框中提到的工作表名称

excel - VBA 循环 : Automate web form filling

Excel 公式 - 如何有条件地用另一个表中的值填充列

sql - 计算高数量级计数(100,000+)的匹配行数

PostgreSQL 使用复制功能后无法进行简单查询