SqlException: A connection was successfully established with the server, but then an error occurred during the login process.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 year ago
I downloaded the nopCommerce project from Github and on the first run, this is the error I get:

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.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)

DependencyResolutionException: An exception was thrown while activating λ:Nop.Core.Domain.Common.CommonSettings.
Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action<ResolveRequestContext> next)

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

Please assist. I see on the internet some solutions suggest setting the Trusted Server Certificate to True but that seems to be the case already. I'm also a bit unsure where such a connection string would be located in the code.
1 year ago
Hi,
The "Trusted Server Certificate = True" or "Encrypt = False" can be added (or be found) inside the  connection string in the \App_Data\appsettings.json file.
1 year ago
For the first run, this file \App_Data\appsettings.json does not exist.
1 year ago
Yes, true.
I have mentioned the appsettings.json file because of this (" I'm also a bit unsure where such a connection string would be located in the code").

Are you using the latest version of nopCommerce? - i can see autofac (IoC) in the error info which is quite strange.
   -Trusted Server Certificate =True or (Encrypt = false) params are only related to the nopCommerce version 4.50.

Also please check out this link https://docs.microsoft.com/en-us/troubleshoot/sql/connect/error-message-when-you-connect
1 year ago
I'm using the latest from the develop branch in the nopCommerce repo. I also went to the mentioned azure documentation. It didn't help.

I'm seeing more info that can help debug this. The error is being thrown at line 234 in nopCommerce\src\Libraries\Nop.Data\EntityRepository.cs. When I look at the query object on that line, it has a DataContext object  (of type LinqToDB.DataContext). That object has a ConnectionString attribute in it that looks like the following: Data Source=localhost;Initial Catalog=nopCommerce;Integrated Security=True;Persist Security Info=False

That's where the error is being thrown at. Could the connection string be the issue?

This is a link to the debugging session image that has the info aforementioned:
https://drive.google.com/file/d/1bZgxtcgrtlm5Snzc8AjM-MiBNW7csJJX/view
1 year ago
I have just downloaded the code from the develop branch too.
I'm using Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64)   Sep 24 2019 13:48:23   Copyright (C) 2019 Microsoft Corporation  Express Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 19044: ) .

This is how i have configured the /install step:
https://prnt.sc/miendiMKoMft

The install process went ok without a problem (Visual Studio 2022).
The generated appsettings.json file:
https://prnt.sc/tPYD33IAfxRx

Nop its running without a problem:
https://prnt.sc/iBmj_hIu8XWO
1 year ago
Thanks for your help, Daniel. I was able to run the project after deleting the project and downloading it anew. I had an old copy of the repo to which I git pulled the latest changes. It probably didn't update to the exact latest copy of the repo. That's why I was getting the errors but it's all working fine now.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.