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

Smith
Smith
Participant
374 Points
112 Posts

I'm getting following error when try to migrate db in my local machine DB:

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.)
Application startup exception: System.Data.SqlClient.SqlException (0x80131904): 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.) ---> System.ComponentModel.Win32Exception (0x80090325): The certificate chain was issued by an authority that is not trusted
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(Boolean buffer)
   at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)

What is wrong here with my connection?

Views: 106
Total Answered: 2
Total Marked As Answer: 0
Posted On: 24-Apr-2019 23:29

Share:   fb twitter linkedin
Answers
beginer
beginer
72 Points
31 Posts
     

SQL server likely don't have a CA signed certificate installed in your local SQL machine trusted root store.

If you are using Encrypt=True in the connection string, either set that to off (not recommended), or add the following in the connection string:
TrustServerCertificate=True
SQL Server will create a self-signed certificate if you don't install one for it to use, but it won't be trusted by the caller since it's not CA-signed, unless you tell the connection string to trust any server cert by default.

Posted On: 26-Apr-2019 22:30
Jak
Jak
Member
354 Points
152 Posts
     

I was facing same problem, following setting

TrustServerCertificate=True

resolved.

Posted On: 18-May-2019 05:39
banner

Blog

Active User (1)

 Log In to Chat