UnauthorizedAccessException: Access to the path 'c:\windows\system32\inetsrv\tempkey.rsa' is denied."

Viewed 4567

I was trying to deploy an Identity Server 4 app with asp.net core 2.2 into IIS in my local machine (Windows 10) and get the error "An error occurred while starting the application. get the error "An error occurred while starting the application. UnauthorizedAccessException: Access to the path 'c:\windows\system32\inetsrv\tempkey.rsa' is denied."

Its working with debugging mode but getting above while deploying in IIS.

Identity server 4 version - 2.3.2

Asp.net core 2.2

IIS 10.0.16

Can anyone help to solve this?

2 Answers

I had the same error and it was coming from the call to AddDeveloperSigningCredential() inside configure services. When I changed it to AddDeveloperSigningCredential( persistKey: false ), the error went away.

Here is entire function call block

public void ConfigureServices( IServiceCollection services )
{
    services.AddIdentityServer()
    .AddDeveloperSigningCredential( persistKey:false)
    .AddInMemoryApiResources( Config.GetApiResources() )
    .AddInMemoryClients( Config.GetClients() );
}

Change the app pool identity to LocalSystem. Or give access to whatever app pool identity you are using to that location.

Related