Skip to content

Commit 0ca63d8

Browse files
committed
Fixes for enabled.
1 parent f34c920 commit 0ca63d8

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public GlobalSignApiClient(GlobalSignCAConfig config, ILogger logger)
2727
Config = config;
2828
// Logger = LogHandler.GetClassLogger(this.GetType());
2929
var enabled =config.Enabled;
30-
if (enabled)
30+
if (!enabled)
3131
{
3232
Logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping config validation and MSSL Client creation...");
3333
Logger.MethodExit();

globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -457,19 +457,18 @@ public async Task ValidateCAConnectionInfo(Dictionary<string, object> connection
457457
{
458458
Logger = LogHandler.GetClassLogger(GetType());
459459
Logger.MethodEntry();
460-
try
461-
{
462-
if (!(bool)connectionInfo["Enabled"])
463-
{
464-
Logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation...");
465-
Logger.MethodExit(LogLevel.Trace);
466-
return;
467-
}
468-
}
469-
catch (Exception ex)
460+
461+
// Handle Enabled flag - could be bool or string
462+
var enabledValue = connectionInfo["Enabled"];
463+
bool isEnabled = enabledValue is bool ? (bool)enabledValue : bool.Parse((string)enabledValue);
464+
465+
if (!isEnabled)
470466
{
471-
Logger.LogError($"Exception: {LogHandler.FlattenException(ex)}");
467+
Logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation...");
468+
Logger.MethodExit(LogLevel.Trace);
469+
return;
472470
}
471+
473472
Config = new GlobalSignCAConfig
474473
{
475474
IsTest = bool.Parse((string)connectionInfo["TestAPI"]),
@@ -482,6 +481,7 @@ public async Task ValidateCAConnectionInfo(Dictionary<string, object> connection
482481
ORDER_TEST_URL = (string)connectionInfo["OrderAPITestURL"],
483482
QUERY_TEST_URL = (string)connectionInfo["QueryAPITestURL"],
484483
QUERY_PROD_URL = (string)connectionInfo["QueryAPIProdURL"],
484+
Enabled = isEnabled,
485485
SyncStartDate = connectionInfo.TryGetValue("SyncStartDate", out object? value)
486486
? (string)value : string.Empty,
487487
SyncIntervalDays = connectionInfo.TryGetValue("SyncIntervalDays", out var val)
@@ -497,6 +497,17 @@ public async Task ValidateCAConnectionInfo(Dictionary<string, object> connection
497497

498498
public Task ValidateProductInfo(EnrollmentProductInfo productInfo, Dictionary<string, object> connectionInfo)
499499
{
500+
// Handle Enabled flag - could be bool or string
501+
var enabledValue = connectionInfo["Enabled"];
502+
bool isEnabled = enabledValue is bool ? (bool)enabledValue : bool.Parse((string)enabledValue);
503+
504+
if (!isEnabled)
505+
{
506+
Logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation...");
507+
Logger.MethodExit(LogLevel.Trace);
508+
return Task.CompletedTask;
509+
}
510+
500511
Config = new GlobalSignCAConfig
501512
{
502513
IsTest = bool.Parse((string)connectionInfo["TestAPI"]),
@@ -509,6 +520,7 @@ public Task ValidateProductInfo(EnrollmentProductInfo productInfo, Dictionary<st
509520
ORDER_TEST_URL = (string)connectionInfo["OrderAPITestURL"],
510521
QUERY_TEST_URL = (string)connectionInfo["QueryAPITestURL"],
511522
QUERY_PROD_URL = (string)connectionInfo["QueryAPIProdURL"],
523+
Enabled = isEnabled,
512524
SyncStartDate = connectionInfo.TryGetValue("SyncStartDate", out object? value)
513525
? (string)value : string.Empty,
514526
SyncIntervalDays = connectionInfo.TryGetValue("SyncIntervalDays", out var val)

0 commit comments

Comments
 (0)