Problem with establishing encrypted connection to SQL server from your application

Error encountered when connecting to SQL server with encrypted connection from your application (Classic ASP, ASP.NET, .NET Core, and PHP).
The certificate chain was issued by an authority that is not trusted.

Reason:
This error occurs because a self-signed certificate is being used for encrypted connections on our SQL server.

To resolve this issue:
For Classic ASP/ASP.NET/.NET Core applications, update your connection string with the following:
"Data Source=DBSERVERNAME;Initial Catalog=YOURDATABASENAME;User ID=YOURUSERID;Password=YOURPASSWORD;Encrypt=yes;TrustServerCertificate=true"

For PHP applications add the following:
$connectionInfo = array( "Database"=>"YOURDBNAME", "UID"=>"YOURUSERID", "PWD"=>"YOURPASSWORD","Encrypt"=>true,"TrustServerCertificate"=>true);