-
Notifications
You must be signed in to change notification settings - Fork 1
Enabledflg #4
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
Enabledflg #4
Changes from all commits
ab06924
cdb4ee8
6780abd
0c8a460
d548c9c
9ef6157
c31c19b
aadca62
c08a852
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| - 1.1.0 | ||
| - Enabled Flag For Gateway | ||
| - Dual Build Support | ||
| - 1.0.0 | ||
| - Conversion to REST Framework | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||
| using DigicertMpkiSoap; | ||||||||||||||
| using DigicertMpkiSoap; | ||||||||||||||
| using Keyfactor.AnyGateway.DigicertMpki; | ||||||||||||||
| using Keyfactor.AnyGateway.DigicertMpki.Client.Models; | ||||||||||||||
| using Keyfactor.AnyGateway.Extensions; | ||||||||||||||
|
|
@@ -43,6 +43,13 @@ | |||||||||||||
| _config = DeserializeConfig(configProvider.CAConnectionData); | ||||||||||||||
| _logger.MethodEntry(); | ||||||||||||||
|
|
||||||||||||||
| if (!_config.Enabled) | ||||||||||||||
| { | ||||||||||||||
| _logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations."); | ||||||||||||||
| _logger.MethodExit(LogLevel.Trace); | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| _requestManager = new RequestManager(_logger, _config); | ||||||||||||||
| _client = new DigiCertSymClient(_config, _logger); | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -106,7 +113,7 @@ | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private async Task ProcessProductModel(string productModel, BlockingCollection<AnyCAPluginCertificate> blockingBuffer, CancellationToken cancelToken) | ||||||||||||||
|
Check warning on line 116 in digicert-mpki-caplugin/DigicertMpkiCAPlugin.cs
|
||||||||||||||
| { | ||||||||||||||
| int pageCounter = 0; | ||||||||||||||
| const int pageSize = 50; | ||||||||||||||
|
|
@@ -293,10 +300,23 @@ | |||||||||||||
| StatusMessage = $"Enrollment Failed: {errorMessage}" | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| public async Task Ping() => _logger.LogTrace("Ping successful."); | ||||||||||||||
|
Check warning on line 303 in digicert-mpki-caplugin/DigicertMpkiCAPlugin.cs
|
||||||||||||||
|
|
||||||||||||||
| public async Task ValidateCAConnectionInfo(Dictionary<string, object> connectionInfo) | ||||||||||||||
|
Check warning on line 305 in digicert-mpki-caplugin/DigicertMpkiCAPlugin.cs
|
||||||||||||||
| { | ||||||||||||||
| try | ||||||||||||||
| { | ||||||||||||||
| if (!(bool)connectionInfo[Constants.Enabled]) | ||||||||||||||
| { | ||||||||||||||
| _logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation..."); | ||||||||||||||
|
Comment on lines
+309
to
+311
|
||||||||||||||
| if (!(bool)connectionInfo[Constants.Enabled]) | |
| { | |
| _logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation..."); | |
| if (!connectionInfo.TryGetValue(Constants.Enabled, out object enabledObj) || !(enabledObj is bool enabled) || !enabled) | |
| { | |
| _logger.LogWarning($"The CA is currently in the Disabled state or the Enabled flag is missing/invalid. It must be Enabled to perform operations. Skipping validation..."); |
Copilot
AI
Oct 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block logs the exception but continues execution, which could lead to unexpected behavior. The method should either handle the missing Enabled key gracefully or rethrow the exception after logging.
| _logger.LogError($"Exception: {LogHandler.FlattenException(ex)}"); | |
| _logger.LogError($"Exception: {LogHandler.FlattenException(ex)}"); | |
| throw; |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block logs the exception but doesn't handle it, allowing execution to continue to line 320 even when an exception occurs accessing connectionInfo[Constants.Enabled]. This could lead to unexpected behavior. Either rethrow the exception after logging, or ensure the validation logic at line 320 can handle the error state appropriately.
| _logger.LogError($"Exception: {LogHandler.FlattenException(ex)}"); | |
| _logger.LogError($"Exception: {LogHandler.FlattenException(ex)}"); | |
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct cast to bool will throw InvalidCastException if the value is null or not a boolean type. Use safer casting like 'connectionInfo.TryGetValue(Constants.Enabled, out var enabledValue) && enabledValue is bool enabled && !enabled' or provide a default value with 'as bool? ?? true'.