Skip to content
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

Add Enabled config flag #6

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@ -394,7 +401,7 @@
/// </summary>
/// <param name="caRequestID">The gateway request ID of the record to retrieve, in the format 'orderID-certID'</param>
/// <returns></returns>
public async Task<AnyCAPluginCertificate> GetSingleRecord(string caRequestID)

Check warning on line 404 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 404 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);
// Split ca request id into order and cert id
Expand Down Expand Up @@ -481,9 +488,17 @@
/// </summary>
/// <returns></returns>
/// <exception cref="Exception"></exception>
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 @@ -515,7 +530,7 @@
/// <returns></returns>
/// <exception cref="COMException"></exception>
/// <exception cref="Exception"></exception>
public async Task<int> Revoke(string caRequestID, string hexSerialNumber, uint revocationReason)

Check warning on line 533 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 533 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);
int orderId = Int32.Parse(caRequestID.Substring(0, caRequestID.IndexOf('-')));
Expand Down Expand Up @@ -573,7 +588,7 @@
/// <param name="cancelToken"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockingBuffer, DateTime? lastSync, bool fullSync, CancellationToken cancelToken)

Check warning on line 591 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 591 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);

Expand Down Expand Up @@ -690,9 +705,23 @@
/// </summary>
/// <param name="connectionInfo"></param>
/// <returns></returns>
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 Expand Up @@ -747,7 +776,7 @@
/// <param name="connectionInfo"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Dictionary<string, object> connectionInfo)

Check warning on line 779 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 779 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);
// Set up.
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
Loading