SQL Server: 证书链是由一个不受信任的颁发机构颁发的

huangapple go评论146阅读模式
英文:

SQL Server: The certificate chain was issued by an authority that is not trusted

问题

ADDITIONAL INFORMATION:

与服务器成功建立了连接,但在登录过程中发生了错误。
(provider: SSL提供程序,错误:0 - 证书链
由不受信任的授权机构颁发。)
(Microsoft SQL Server,错误:-2146893019)

错误编号:-2146893019
严重程度:20
状态:0

程序位置:

在 Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,Boolean breakConnection,Action1 wrapCloseInAction) 在 Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose) 在 Microsoft.Data.SqlClient.TdsParserStateObject.SNIWritePacket(SNIHandle handle,SNIPacket packet,UInt32& sniError,Boolean canAccumulate,Boolean callerHasConnectionLock) 在 Microsoft.Data.SqlClient.TdsParserStateObject.WriteSni(Boolean canAccumulate) 在 Microsoft.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode,Boolean canAccumulate) 在 Microsoft.Data.SqlClient.TdsParser.TdsLogin(SqlLogin rec,FeatureExtension requestedFeatures,SessionData recoverySessionData,FederatedAuthenticationFeatureExtensionData fedAuthFeatureExtensionData,SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo) 在 Microsoft.Data.SqlClient.SqlInternalConnectionTds.Login(ServerInfo server,TimeoutTimer timeout,String newPassword,SecureString newSecurePassword) 在 Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword,Boolean ignoreSniOpenTimeout,TimeoutTimer timeout,Boolean withFailover,Boolean isFirstTransparentAttempt,Boolean disableTnir) 在 Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString connectionOptions,SqlCredential credential,TimeoutTimer timeout) 在 Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout,SqlConnectionString connectionOptions,SqlCredential credential,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance) 在 Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity,SqlConnectionString connectionOptions,SqlCredential credential,Object providerInfo,String newPassword,SecureString newSecurePassword,Boolean redirectedUserInstance,SqlConnectionString userConnectionOptions,SessionData reconnectSessionData,ServerCertificateValidationCallback serverCallback,ClientCertificateRetrievalCallback clientCallback,DbConnectionPool pool,String accessToken,SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo,Boolean applyTransientFaultHandling) 在 Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool pool,DbConnection owningConnection,DbConnectionOptions userOptions) 在 Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup,DbConnectionOptions userOptions) 在 Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection,TaskCompletionSource1 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& connection)
在 Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 retry,DbConnectionOptions userOptions) 在 Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource1 retry,DbConnectionOptions userOptions)
在 Microsoft.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) 在 Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry,SqlConnectionOverrides overrides)
在 Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
在 Microsoft.Data.SqlClient.SqlConnection.Open()
在 Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci,IServerType server)
在 Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

成功连接到SQL Server。

英文:

> ADDITIONAL INFORMATION:
>
> A connection was successfully established with the server,
but then an error occurred during the login process.
(provider: SSL Provider, error: 0 - The certificate chain
was issued by an authority that is not trusted.)
(Microsoft SQL Server, Error: -2146893019)
>
> Error Number: -2146893019
> Severity: 20
> State: 0
>
> Program Location:
>
> at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
> at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
> at Microsoft.Data.SqlClient.TdsParserStateObject.SNIWritePacket(SNIHandle handle, SNIPacket packet, UInt32& sniError, Boolean canAccumulate, Boolean callerHasConnectionLock)
> at Microsoft.Data.SqlClient.TdsParserStateObject.WriteSni(Boolean canAccumulate)
at Microsoft.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode, Boolean canAccumulate)
at Microsoft.Data.SqlClient.TdsParser.TdsLogin(SqlLogin rec, FeatureExtension requestedFeatures, SessionData recoverySessionData, FederatedAuthenticationFeatureExtensionData fedAuthFeatureExtensionData, SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.Login(ServerInfo server, TimeoutTimer timeout, String newPassword, SecureString newSecurePassword)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover, Boolean isFirstTransparentAttempt, Boolean disableTnir)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, ServerCertificateValidationCallback serverCallback, ClientCertificateRetrievalCallback clientCallback, DbConnectionPool pool, String accessToken, SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo, Boolean applyTransientFaultHandling)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1 retry, SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

Connect to SQL Server properly

答案1

得分: 5

对于 SQL Developer 2019:

  • 打开 SQL Server Management Studio
  • 选择您的实例
  • 单击选项
  • 转到连接属性
  • 选择“信任服务器证书”
  • 单击连接

SQL Server: 证书链是由一个不受信任的颁发机构颁发的

英文:

For SQL Developer 2019

  • Open SQL Server Management Studio

  • Select the instance of your choice

  • Click on the options

  • Go to the connection properties

  • Select the "Trust Server Certificate"

  • Click on connect

    SQL Server: 证书链是由一个不受信任的颁发机构颁发的

答案2

得分: 1

尝试将 "TrustServerCertificate=True;" 添加到您的连接字符串中。

英文:

Try adding TrustServerCertificate=True; to your connection string.

huangapple
  • 本文由 发表于 2023年2月19日 18:41:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定