London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Upgraded to .NET 6 and updated all framework packages updates but get initialization error. Please advise

Vote:
 

An error occurred while starting the application.

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

Unknown location

SqlException: 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.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose)

InitializationException: Initialize action failed for Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.11.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7

EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

  • Win32Exception: The certificate chain was issued by an authority that is not trusted.


    • Show raw exception details
    • SqlException: 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.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose)

      • Microsoft.Data.SqlClient.TdsParserStateObject.SNIWritePacket(PacketHandle packet, out uint sniError, bool canAccumulate, bool callerHasConnectionLock, bool asyncClose)

      • Microsoft.Data.SqlClient.TdsParserStateObject.WriteSni(bool canAccumulate)

      • Microsoft.Data.SqlClient.TdsParserStateObject.WritePacket(byte flushMode, bool canAccumulate)

      • Microsoft.Data.SqlClient.TdsParser.TdsLogin(SqlLogin rec, FeatureExtension requestedFeatures, SessionData recoverySessionData, FederatedAuthenticationFeatureExtensionData fedAuthFeatureExtensionData, SqlConnectionEncryptOption encrypt)

      • Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, string newPassword, SecureString newSecurePassword, bool ignoreSniOpenTimeout, TimeoutTimer timeout, bool withFailover)

      • Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)

      • Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance)

      • Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, object providerInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, bool applyTransientFaultHandling, string accessToken, DbConnectionPool pool)

      • Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

      • Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

      • Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

      • Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

      • Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection)

      • Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, out DbConnectionInternal connection)

      • Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, out DbConnectionInternal connection)

      • Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource<DbConnectionInternal> retry, DbConnectionOptions userOptions)

      • Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource<DbConnectionInternal> retry, SqlConnectionOverrides overrides)

      • Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)

      • EPiServer.Data.Providers.Internal.ConnectionContext.<OpenConnection>b__15_0()

      • EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute<TResult>(Func<TResult> method)

      • EPiServer.Data.Providers.Internal.ConnectionContext.OpenConnection()

      • EPiServer.Data.Internal.MARSConnectionContextHandler.CreateConnectionScope(bool requireTransaction, Action completeAction)

      • EPiServer.Data.Providers.Internal.SqlDatabaseExecutor+<>c__DisplayClass24_0<TResult>.<Execute>b__0()

      • EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute<TResult>(Func<TResult> method)

      • EPiServer.Data.SchemaUpdates.Internal.DatabaseVersionRetriever.GetDatabaseVersion(bool forceRefresh)

      • EPiServer.Data.SchemaUpdates.Internal.DatabaseVersionValidator.GetStatus(IEnumerable<ConnectionStringOptions> connectionStringOptions)

      • EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation+<>c__DisplayClass6_0.<EnsureDatabaseSchema>b__0(ISchemaUpdater u)

      • System.Linq.Enumerable+SelectIPartitionIterator<TSource, TResult>.ToList()

      • EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation.EnsureDatabaseSchema(DataAccessOptions dataAccessOptions)

      • EPiServer.Data.DataInitialization.Initialize(InitializationEngine context)

      • EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, string key)

      • EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)

      • EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()


    • Show raw exception details
    • InitializationException: Initialize action failed for Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.11.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7

      • EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

      • EPiServer.Framework.Initialization.InitializationEngine.ExecuteTransition(bool continueTransitions)

      • EPiServer.Framework.Initialization.InitializationEngine.Initialize()

      • EPiServer.Hosting.Internal.EPiServerFrameworkHost.StartAsync(CancellationToken cancellationToken)

      • Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)

      • Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

      • Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

      • Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)

      • QDX.Program.Main(string[] args) in Program.cs

        +
        1. CreateHostBuilder(args).Build().Run();
    #293160
    Edited, Dec 14, 2022 20:30
    Vote:
     

    Did this happen when upgradeing from .Net Framework 4.x to .Net 6 or when you went from .Net 5 to .Net 6 ?

    Are you connecting to an On Prem (Local) Sql Server Database or Azure SQL ? 

    Is TLS 1.2 enabled ? 

    What does your connection string look like ? Try setting Encrypt=False 

    #293163
    Dec 14, 2022 21:21
    Vote:
     

    It happened when I went from .NET 5 to .NET 6. Its connection to On Prem Local SQL DB. How do I check if TLS 1.2 is enabled?

    Anyhow, I added TrustServerCertificate=True, that helped resolve it?

    Thanks

    #293168
    Dec 14, 2022 22:46
    Vote:
     

    Daman, I got caught out by this at first.  The default encryption state for SQL connectivity has changed with the move from Microsoft.Data.SqlClient v3.x.x to v4.x.x

    EPiServer.Framework uses Microsoft.Data.SqlClient v3.x.x for .NET 5 and Microsoft.Data.SqlClient v4.x.x .NET 6 (or v5.x.x if you update EPiServer.Framework 12.11.0)

    #293207
    Dec 15, 2022 11:19
    * You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.