dotnet / dotnet/aspnetcore

Kestrel Configuration Reload Certificate ArgumentNullException

Open
#64,307 0 comments 0 reactions 0 assignees View on GitHub
area-networking feature-kestrel
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

When having appsettings reload enabled and changing the Kestrel HTTPS certificate while the app is running an exception is thrown.

### Expected Behavior

No exception is thrown.

### Steps To Reproduce

Program.cs
```cs
WebApplication.CreateBuilder(args);
// this is enabled by default:
builder.Configuration.AddJsonFile("appsettings.json", true, reloadOnChange: true);
```

Change appsettings.json Kestrel.Certificates to another one while having the aplication running
```json
"Kestrel": {
"Certificates": {
"Default": {
"Subject": "www.contoso.com", //change to another one
"Store": "My",
"Location": "LocalMachine"
}
}
}
```

### Exceptions (if any)

"Unable to reload configuration."
System.ArgumentNullException: Value cannot be null. (Parameter 'path2')
at System.ArgumentNullException.Throw(String paramName)
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.CertificatePathWatcher.RemoveWatchUnsynchronized(CertificateConfig certificateConfig)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.CertificatePathWatcher.UpdateWatches(List`1 certificateConfigsToRemove, List`1 certificateConfigsToAdd)
at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.RebindAsync()

### .NET Version

10.0.100-rc.2.25502.107

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.