Skip to content

Add missing directory creation to fix certificate export issue. - #593

Merged
Damian Edwards (DamianEdwards) merged 1 commit into
microsoft:damianedwards/keycloak-samplefrom
yellow444:magnmaks/keycloak-sample-fix
Dec 2, 2024
Merged

Add missing directory creation to fix certificate export issue.#593
Damian Edwards (DamianEdwards) merged 1 commit into
microsoft:damianedwards/keycloak-samplefrom
yellow444:magnmaks/keycloak-sample-fix

Conversation

@yellow444

@yellow444 Maksim (yellow444) commented Nov 27, 2024

Copy link
Copy Markdown

Summary

This PR addresses issue #416 related to an error that occurs during certificate export when the specified directory does not exist. The issue was caused by the lack of a check or creation step for the directory before attempting to export the certificate.
Root Cause

When exporting the certificate, the CertificateManager throws a System.InvalidOperationException if the target directory is missing. The error message highlights that the directory does not exist and emphasizes the need for careful permission settings when creating it.
Fix

Added a line to ensure the target directory is created before exporting the certificate:

Directory.CreateDirectory(tempDir);

Impact

This change prevents the InvalidOperationException and ensures smooth certificate export without requiring manual intervention to create the directory. It also aligns the process with best practices for error handling and directory management.
Testing

Verified that the directory is created automatically if it does not exist.
Confirmed successful certificate export without errors.

Additional Notes

This fix improves usability and reliability when working with certificate export functionalities. Feedback and further suggestions are welcome!

@yellow444

Copy link
Copy Markdown
Author

#416

@yellow444
Maksim (yellow444) marked this pull request as ready for review November 27, 2024 04:48
@DamianEdwards

Copy link
Copy Markdown
Member

Thanks for this. I actually found this too when updating the Node sample to use the dev cert as you can see at: https://github.com/dotnet/aspire-samples/blob/cc0d6b4c28d1f664e74eeccb911c7f23c2950510/samples/Shared/DevCertHostingExtensions.cs#L103-L108

I'll merge this in and when I circle back to the Keycloak sample I'll update it to use the now committed shared logic.

@DamianEdwards
Damian Edwards (DamianEdwards) merged commit e20ba38 into microsoft:damianedwards/keycloak-sample Dec 2, 2024
David Pine (IEvangelist) pushed a commit that referenced this pull request Jul 30, 2026
…st-uri, protobufjs)

Clears 14 Dependabot alerts via verified clean single-entry lockfile swaps
(deps unchanged, parent ranges satisfied, integrity cross-verified vs npmjs SHA-1):
- brace-expansion 5.0.5 -> 5.0.7 x9 roots (#590,#592,#593,#594,#595,#596,#597,#598,#599)
- brace-expansion 2.1.1 -> 2.1.2 aspire-with-node/api (#655)
- brace-expansion 2.0.3 -> 2.1.2 and 1.1.13 -> 1.1.16 aspire-with-node/frontend (#658,#657)
- fast-uri 3.1.3 -> 3.1.4 AspireJavaScript.React (#626)
- protobufjs 7.6.4 -> 7.6.5 polyglot-task-queue/api (#615)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
David Pine (IEvangelist) pushed a commit that referenced this pull request Jul 31, 2026
…st-uri, protobufjs)

Clears 14 Dependabot alerts via verified clean single-entry lockfile swaps
(deps unchanged, parent ranges satisfied, integrity cross-verified vs npmjs SHA-1):
- brace-expansion 5.0.5 -> 5.0.7 x9 roots (#590,#592,#593,#594,#595,#596,#597,#598,#599)
- brace-expansion 2.1.1 -> 2.1.2 aspire-with-node/api (#655)
- brace-expansion 2.0.3 -> 2.1.2 and 1.1.13 -> 1.1.16 aspire-with-node/frontend (#658,#657)
- fast-uri 3.1.3 -> 3.1.4 AspireJavaScript.React (#626)
- protobufjs 7.6.4 -> 7.6.5 polyglot-task-queue/api (#615)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
David Pine (IEvangelist) pushed a commit that referenced this pull request Aug 3, 2026
…st-uri, protobufjs)

Clears 14 Dependabot alerts via verified clean single-entry lockfile swaps
(deps unchanged, parent ranges satisfied, integrity cross-verified vs npmjs SHA-1):
- brace-expansion 5.0.5 -> 5.0.7 x9 roots (#590,#592,#593,#594,#595,#596,#597,#598,#599)
- brace-expansion 2.1.1 -> 2.1.2 aspire-with-node/api (#655)
- brace-expansion 2.0.3 -> 2.1.2 and 1.1.13 -> 1.1.16 aspire-with-node/frontend (#658,#657)
- fast-uri 3.1.3 -> 3.1.4 AspireJavaScript.React (#626)
- protobufjs 7.6.4 -> 7.6.5 polyglot-task-queue/api (#615)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants