Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static signing in hosts #1661

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Fix static signing in hosts #1661

merged 1 commit into from
Dec 11, 2024

Conversation

josephdecock
Copy link
Member

@josephdecock josephdecock commented Dec 7, 2024

Constructing an X509Certificate2 instance for a p12 file is problematic. The private key gets stored in a temp file, which is discarded when the X509Certificate2 instance is disposed. That causes problems for us, as the public key material is in our store, but the private key no longer exists on disk.

Instead of instantiating, we should store the certificate in the OS store, and load the cert that we need from there.

Also, the test certs that were checked in were generated with mkcert. We can't share those certs, because a distinct mkcert root certificate is generated on each developer's machine. This means that the identity server test certificates I generate won't be trusted by another machine, unless it also trusts my mkcert root certificate. And we won't do that, because it would give me the power to create fraudulent certificates that other dev's machines would trust. Instead, we just remove the test certs from source control and have a comment in the source to use mkcert and add the certs to the OS store. The manual signing credentials are not used by default, so this seems like an acceptable compromise.

@josephdecock josephdecock requested a review from damianh December 7, 2024 20:28
@@ -35,7 +35,6 @@ internal static WebApplicationBuilder ConfigureIdentityServer(this WebApplicatio
.AddInMemoryIdentityResources(Resources.IdentityResources)
.AddInMemoryApiScopes(Resources.ApiScopes)
.AddInMemoryApiResources(Resources.ApiResources)
//.AddStaticSigningCredential()
Copy link
Member Author

@josephdecock josephdecock Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm deleting this entirely from the configuration host - there's no need to fix this in both main and configuration hosts.

@josephdecock josephdecock linked an issue Dec 7, 2024 that may be closed by this pull request
@josephdecock josephdecock merged commit 62df123 into main Dec 11, 2024
5 checks passed
@josephdecock josephdecock deleted the joe/static-signing branch December 19, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manually test static signing credentials from x509 certs
2 participants