c# 连接 sql server 数据库时报错,证书链是由不受信任的颁发机构颁发的。

c# 连接 sql server 数据库时报错:A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)

 

Our development database server was recently given a self-signed certificate so it automatically became untrusted. This resulted in the login error cited above. I added TrustServerCertificate=True to my connection string and it works now.

"Server=TheServerAddress; Database=TheDataBase; User Id=TheUsername; Password=ThePassword; TrustServerCertificate=True"

NOTE: This certificate configuration is not recommended for production environments.

posted @ 2023-03-22 19:11  stone8386  阅读(3473)  评论(0编辑  收藏  举报