Skip to content

Commit cb944f6

Browse files
committed
Add enabled flag
1 parent 5e2ca2a commit cb944f6

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

digicert-mpki-caplugin/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public class Constants
1313
public static string EmailConstName = "EmailConstName";
1414
public static string UpnConstName = "UpnConstName";
1515
public static string OuStartPoint = "OuStartPoint";
16+
public static string Enabled = "Enabled";
1617
}
1718
}

digicert-mpki-caplugin/DigicertMpkiCAPlugin.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public void Initialize(IAnyCAPluginConfigProvider configProvider, ICertificateDa
4343
_config = DeserializeConfig(configProvider.CAConnectionData);
4444
_logger.MethodEntry();
4545

46+
if (!_config.Enabled)
47+
{
48+
_logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations.");
49+
_logger.MethodExit(LogLevel.Trace);
50+
return;
51+
}
52+
4653
_requestManager = new RequestManager(_logger, _config);
4754
_client = new DigiCertSymClient(_config, _logger);
4855

@@ -297,6 +304,19 @@ private async Task<EnrollmentResult> ProcessRenewEnrollment(string csr, Enrollme
297304

298305
public async Task ValidateCAConnectionInfo(Dictionary<string, object> connectionInfo)
299306
{
307+
try
308+
{
309+
if (!(bool)connectionInfo[Constants.Enabled])
310+
{
311+
_logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation...");
312+
_logger.MethodExit(LogLevel.Trace);
313+
return;
314+
}
315+
}
316+
catch (Exception ex)
317+
{
318+
_logger.LogError($"Exception: {LogHandler.FlattenException(ex)}");
319+
}
300320
List<string> errors = ValidateConnectionInfo(connectionInfo);
301321
if (errors.Any())
302322
ThrowValidationException(errors);
@@ -372,6 +392,13 @@ public Dictionary<string, PropertyConfigInfo> GetCAConnectorAnnotations()
372392
Hidden = false,
373393
DefaultValue = "",
374394
Type = "String"
395+
},
396+
[Constants.Enabled] = new PropertyConfigInfo()
397+
{
398+
Comments = "Flag to Enable or Disable gateway functionality. Disabling is primarily used to allow creation of the CA prior to configuration information being available.",
399+
Hidden = false,
400+
DefaultValue = true,
401+
Type = "Boolean"
375402
}
376403
};
377404
}

digicert-mpki-caplugin/DigicertMpkiConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ public DigicertMpkiConfig()
1717
public string EmailConstName { get; set; }
1818
public string UpnConstName { get; set; }
1919
public int OuStartPoint { get; set; }
20+
public bool Enabled { get; set; } = true;
2021
}
2122
}

0 commit comments

Comments
 (0)