Skip to content

Commit

Permalink
Merge pull request #6 from Keyfactor/skipvalidation
Browse files Browse the repository at this point in the history
Add Enabled config flag
  • Loading branch information
dgaley authored Mar 11, 2024
2 parents 6730074 + 61fd7e0 commit 33ab07c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions digicert-certcentral-anycagateway/CertCentralCAConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,13 @@ public Dictionary<string, PropertyConfigInfo> GetCAConnectorAnnotations()
Hidden = false,
DefaultValue = false,
Type = "Boolean"
},
[CertCentralConstants.Config.ENABLED] = new PropertyConfigInfo()
{
Comments = "Flag to Enable or Disable gateway functionality. Disabling is primarily used to allow creation of the CA prior to configuration information being available.",
Hidden = false,
DefaultValue = true,
Type = "Boolean"
}
};
}
Expand Down Expand Up @@ -484,6 +491,14 @@ public Dictionary<string, PropertyConfigInfo> GetTemplateParameterAnnotations()
public async Task Ping()

Check warning on line 491 in digicert-certcentral-anycagateway/CertCentralCAConnector.cs

View workflow job for this annotation

GitHub Actions / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 491 in digicert-certcentral-anycagateway/CertCentralCAConnector.cs

View workflow job for this annotation

GitHub Actions / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
_logger.MethodEntry(LogLevel.Trace);
if (!_config.Enabled)
{
_logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping connectivity test...");
_logger.MethodExit(LogLevel.Trace);
return;
}


try
{
CertCentralClient client = CertCentralClientUtilities.BuildCertCentralClient(_config);
Expand Down Expand Up @@ -693,6 +708,20 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
public async Task ValidateCAConnectionInfo(Dictionary<string, object> connectionInfo)

Check warning on line 708 in digicert-certcentral-anycagateway/CertCentralCAConnector.cs

View workflow job for this annotation

GitHub Actions / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 708 in digicert-certcentral-anycagateway/CertCentralCAConnector.cs

View workflow job for this annotation

GitHub Actions / call-dotnet-build-and-release-workflow / dotnet-build-and-release

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
_logger.MethodEntry(LogLevel.Trace);
try
{
if (!(bool)connectionInfo[CertCentralConstants.Config.ENABLED])
{
_logger.LogWarning($"The CA is currently in the Disabled state. It must be Enabled to perform operations. Skipping validation...");
_logger.MethodExit(LogLevel.Trace);
return;
}
}
catch (Exception ex)
{
_logger.LogError($"Exception: {LogHandler.FlattenException(ex)}");
}

List<string> errors = new List<string>();

_logger.LogTrace("Checking the API Key.");
Expand Down
1 change: 1 addition & 0 deletions digicert-certcentral-anycagateway/CertCentralConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class CertCentralConfig
public string Region { get; set; } = "US";
public int? DivisionId { get; set; }
public bool? RevokeCertificateOnly { get; set; }
public bool Enabled { get; set; } = true;
}
}
1 change: 1 addition & 0 deletions digicert-certcentral-anycagateway/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Config
public const string CA_CERT_ID = "CACertId";
public const string RENEWAL_WINDOW = "RenewalWindowDays";
public const string REVOKE_CERT = "RevokeCertificateOnly";
public const string ENABLED = "Enabled";
}

public class RequestAttributes
Expand Down

0 comments on commit 33ab07c

Please sign in to comment.