异常处理-证书链是由不受信任的颁发机构颁发的
Microsoft.Data.SqlClient.SqlException (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)
异常内容描述
Microsoft.Data.SqlClient.SqlException
HResult=0x80131904
Message=A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)
Source=Core Microsoft SqlClient Data Provider
StackTrace:
在 Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
...
内部异常 1:
Win32Exception: 证书链是由不受信任的颁发机构颁发的。
示例
public const string ReadConnectString = "server=127.0.0.1;database=AdvancedDb;User ID=sa;Password=root;Trust Server Certificate=true";