Feature/correspondence error handling#280
Conversation
Replaced MachineKeySet and Exportable flags with EphemeralKeySet when loading PKCS#12 certificates. This ensures private keys are only stored in memory and not persisted to disk, improving security.
Walkthrough
Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Dan.Core/Program.cs (1)
261-274: Consider extracting the repeated environment check.
Settings.MaskinportenUrl.Contains("test")is evaluated three times (lines 268, 269, 273). While not a correctness issue, extracting it to a local variable would improve readability and ensure consistency if the logic ever changes.♻️ Suggested refactor
void AddAltinn3Messaging(IServiceCollection services) { + var isTestEnvironment = Settings.MaskinportenUrl.Contains("test"); services.AddDdCorrespondenceService(options => { options.MaskinportenSettings = new MaskinportenSettings { ClientId = Settings.MaskinportenClientId, - Environment = Settings.MaskinportenUrl.Contains("test") ? "test" : "prod", - EnableDebugLogging = Settings.MaskinportenUrl.Contains("test"), + Environment = isTestEnvironment ? "test" : "prod", + EnableDebugLogging = isTestEnvironment, EncodedX509 = Convert.ToBase64String(Settings.AltinnCertificate.Export(X509ContentType.Pkcs12)) }; options.ResourceId = "digdir-data-altinn-no-melding"; - options.Environment = Settings.MaskinportenUrl.Contains("test") ? ApiEnvironment.Staging : ApiEnvironment.Production; + options.Environment = isTestEnvironment ? ApiEnvironment.Staging : ApiEnvironment.Production; }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Dan.Core/Program.cs` around lines 261 - 274, Extract the repeated Settings.MaskinportenUrl.Contains("test") boolean check into a local variable at the start of AddAltinn3Messaging (e.g., bool isTest = Settings.MaskinportenUrl.Contains("test")) and use that variable for Environment selection, EnableDebugLogging, and options.Environment assignments so the logic is evaluated once and the code is clearer and consistent across the MaskinportenSettings and options assignments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@Dan.Core/Program.cs`:
- Around line 261-274: Extract the repeated
Settings.MaskinportenUrl.Contains("test") boolean check into a local variable at
the start of AddAltinn3Messaging (e.g., bool isTest =
Settings.MaskinportenUrl.Contains("test")) and use that variable for Environment
selection, EnableDebugLogging, and options.Environment assignments so the logic
is evaluated once and the code is clearer and consistent across the
MaskinportenSettings and options assignments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bbd97ac0-581e-436d-a8dc-b8870d32c28c
📒 Files selected for processing (1)
Dan.Core/Program.cs
Description
Documentation
Summary by CodeRabbit