Troubleshooting Sitecore Identity Server “Sorry, there was an error” Login Issue

Recently I installed Vanilla Sitecore 10.4.1 using install assistant (Graphical Installer) and when I tried to login using identity server I face this error

Sorry, there was an error

The message does not provide enough information to identify the actual problem. I thought lets check the logs which should have more information about the actual error. To my surprise there was no logs for the identity server. The logs folder did not even exist. I therefore had to first find a way to make Identity server start storing logs so I can see the actual error.

Enable Sitecore Identity Server Logs

The existing sitecorehost.xml already contains the logging configuration. No changes are required there.

To capture the actual runtime exception, enable ASP.NET Core stdout logging.

Open:

C:\inetpub\wwwroot\<identity-server-site>\web.config

Find the aspNetCore element:

stdoutLogEnabled="false"

Change it to:

stdoutLogEnabled="true"

Example:

<aspNetCore 
    processPath="dotnet"
    arguments="..."
    stdoutLogEnabled="true"
    stdoutLogFile=".\logs\stdout" />

Create the logs folder if it does not exist:

C:\inetpub\wwwroot\<identity-server-site>\logs

Recycle the Identity Server IIS Application Pool. This is very important step, you can also restart IIS to be on the safe side.

Reproduce the issue and check:

logs\stdout_*.log

The Actual Issue Found

After enabling stdout logging, I was able to see the real error

Microsoft.Data.SqlClient.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.)

Identity Server was failing when connecting to the Sitecore Core database

Resolution

I googled and found that the easiest way to fix it is by updating the connecting string to include TrustServerCertificate=True;

Connection string for identity server can be found in this file

C:\inetpub\wwwroot\<identity-server-site>\Config\production\Sitecore.IdentityServer.Host.xml

Updated connection string:

Data Source=(local);Initial Catalog=site_Core;User ID=securityuser;Password=********;TrustServerCertificate=True;

After updating the connection string and recycling the Identity Server application pool, the Sitecore login started working fine.

Happy Sitecoring 😀

Leave a Reply

Your email address will not be published. Required fields are marked *