Error when ran the generated application: The certificate chain was issued by an authority that is not trusted.

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
joe4010
User
Posts: 5

Error when ran the generated application: The certificate chain was issued by an authority that is not trusted.

Post by joe4010 »

On a different test application I connected to a simple database and generated the code. Once run in localhost:5000 I received this error below. Please help to take a look. I am using SQL server 2016, 2017 version. Thank you.

An unhandled exception occurred while processing the request.
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.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

Stack Query Cookies Headers Routing
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.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)
Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose)
Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(bool callerHasConnectionLock, bool asyncClose)
Microsoft.Data.SqlClient.TdsParserStateObject.SNIWritePacket(PacketHandle packet, out uint sniError, bool canAccumulate, bool callerHasConnectionLock)
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)
Microsoft.Data.SqlClient.SqlInternalConnectionTds.Login(ServerInfo server, TimeoutTimer timeout, string newPassword, SecureString newSecurePassword)
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.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
Microsoft.Data.ProviderBase.DbConnectionFactory+<>c__DisplayClass48_0.<CreateReplaceConnectionContinuation>b__0(Task<DbConnectionInternal> _)
System.Threading.Tasks.ContinuationResultTaskFromResultTask<TAntecedentResult, TResult>.InnerInvoke()
System.Threading.Tasks.Task+<>c.<.cctor>b__272_0(object obj)
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.OpenConnectionAsync() in DatabaseConnectionBase.cs
+
            await c.OpenAsync();
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.OpenConnection() in DatabaseConnectionBase.cs
+
        public virtual N OpenConnection() => OpenConnectionAsync().GetAwaiter().GetResult();
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.<.ctor>b__18_0() in DatabaseConnectionBase.cs
+
            _conn = new Lazy<N>(() => OpenConnection());
System.Lazy<T>.ViaFactory(LazyThreadSafetyMode mode)
System.Lazy<T>.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
System.Lazy<T>.CreateValue()
System.Lazy<T>.get_Value()
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.get_DbConn() in DatabaseConnectionBase.cs
+
        public DbConnection DbConn => (DbConnection)_conn.Value;
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.GetCommand(string sql) in DatabaseConnectionBase.cs
+
            if (Activator.CreateInstance(typeof(M), new object[] { LogSql(sql), DbConn }) is M cmd) {
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.GetDataReaderAsync(string sql) in DatabaseConnectionBase.cs
+
            var cmd = GetCommand(sql); // Use main connection
ASPNETMaker2022.Models.project1+DatabaseConnectionBase<N, M, R, T>.SelectLimit(string sql, int nrows, int offset, bool hasOrderBy) in DatabaseConnectionBase.cs
+
                return await GetDataReaderAsync(sql) ?? await GetDataReaderAsync(originalSql); // If SQL fails due to being too complex, use original SQL.
ASPNETMaker2022.Models.project1+DevicesListBase.LoadRecordset(int offset, int rowcnt) in DevicesList.cs
+
            var dr = await Connection.SelectLimit(sql, rowcnt, offset, !Empty(OrderBy) || !Empty(SessionOrderBy));
ASPNETMaker2022.Models.project1+DevicesListBase.Run() in DevicesList.cs
+
                    Recordset = await LoadRecordset(StartRecord - 1, DisplayRecords);
ASPNETMaker2022.Controllers.HomeController.DevicesList() in DevicesController.cs
+
        return await devicesList.Run();
Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor+TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Runtime.CompilerServices.ValueTaskAwaiter<TResult>.GetResult()
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask<IActionResult> actionResultValueTask)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.HandleResponse(HttpContext httpContext)
Marvin.Cache.Headers.HttpCacheHeadersMiddleware.Invoke(HttpContext httpContext, IValidatorValueInvalidator validatorValueInvalidator)
Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Show raw exception details

End of error

Thanks.


MichaelG
User
Posts: 1095

Post by MichaelG »


joe4010
User
Posts: 5

Post by joe4010 »

Would I press Database tab:
Under Code(Server Events, Client Scripts and Custom Templates)
then insert this code:

//Database Connecting event
public void Database_Connecting(ref string connstr) {
connstr += "TrustServerCertificate=True;";
}

and I only need to put in at this Server Events
Global
Database_Connectin

Thank you.


MichaelG
User
Posts: 1095

Post by MichaelG »

You should use Database_Connecting server event.


joe4010
User
Posts: 5

Post by joe4010 »

Thank you for your help. It worked for the certificate chain issue.

1) Please give instructions how to deploy generated application to IIS web server.

2) On generated application the items on the Main Menu is on the left side of the screen. Please let me know how I can arrange the sequence of items to display. For example, on Northwind database the application generated and display on the choice menu : Orders, Products, Region, Customers. I would like to display in this sequence Customers, Orders, Region, Products on the left Menu side of screen. Thank you!


MichaelG
User
Posts: 1095

Post by MichaelG »

  1. Read the publish setting in:
    https://aspnetmaker.dev/docs/#/generatesetup.html
  2. You can rearrange the menu items in Tools -> Menu Editor. Read:
    https://aspnetmaker.dev/docs/#/tools.html?id=menu

Post Reply