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

When I upgraded to 2022, I always getting the following error:
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.)
Is there any configuration I have to do it in v2022 to get rid of this problem

Please read Database_Connecting example in the documentation:
https://aspnetmaker.dev/docs/#/customscripts.html

Problem solved by the following :

public void Database_Connecting(ref string connstr) {
    
    connStr=connStr + "TrustServerCertificate=True;";
}

Thanks

On a project converted from ANM2019 to ANM 2022.1, this part of code is not being added to appsettings.json or appsettings.Development.json:

public void Database_Connecting(ref string connstr) {

     connstr += "TrustServerCertificate=True;";

}

I have to rewrite each time the json files after each publish.

That’s why you need to use the Database_Connecting server event as suggested.

I was saying that I’m using that event.
But even so, the json files are not being updated, as suggested

The Database_Connecting event doesn’t modify the json file, but that’s OK. When using the example code you gave above, each time ASP.NET Maker connects to the database, it calls Database_Connecting, which adds the parameter to the connection string in memory, which is then used to connect to the database. It worked for me.

I get the error as stated in the first post of this thread, otherwise I would have not posted from beginning.
I simply have no idea how to fix this. Plus the fact in a development environment it makes no sense to implement SQL server certificates. This should not be enforced by a development tool.For the moment being we’re dropping the migration to ANM2022, there are way too many breaking changes.

I was saying that I’m using that event. But even so, the json files are not being updated, as suggested

The Database_Connecting server event does not modify the appsettings json files. It modifies the connection string on the fly at run time. It should work as suggested by many other users on this same thread.

I am getting the error message after logging inThe certificate chain was issued by an authority that is not trustedPlease advise on the correct syntax for the below.// Database Connected event
public void Database_Connected(DbConnection conn) {
// Example:
//conn.Execute(“Your SQL”);
}I changed to

//Database Connecting event
public void Database_Connecting(ref string connstr) {
// Check Info[“id”] for database ID if more than one database
conn.Execute connstr += “TrustServerCertificate=True;”;
}and I am getting the following a build error message

Your codes are wrong. It should be just:connstr += “TrustServerCertificate=True;”;