Skip to content
Open
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@
* Add support for enrolling for client certs
* Option to filter sync by division ID
* Option to provide division ID for enrollment
* Add support for secure_email_* SMIME product types
* Add support for secure_email_* SMIME product types

### 2.1.1
* Add configuration flag to support adding client auth EKU to ssl cert requests
* NOTE: This is a temporary feature which is planned for loss of support by Digicert in May 2026
* For smime certs, use profile type defined on the product as the default if not supplied, rather than just defaulting to 'strict'
* Hotfix for data type conversion

### 2.1.2
* Hotfix for incremental sync to default to a 6 day window if no previous incremental sync has run
* Workaround for DigiCert API issue where retrieving the PEM data of multiple certificates in the same order can occasionally return duplicate data rather than the correct cert
* Remove caching of product ID lookups from DigiCert account
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ An API Key within your Digicert account that has the necessary permissions to en
* **Organization-Name** - OPTIONAL: For requests that will not have a subject (such as ACME) you can use this field to provide the organization name. Value supplied here will override any CSR values, so do not include this field if you want the organization from the CSR to be used.
* **RenewalWindowDays** - OPTIONAL: The number of days from certificate expiration that the gateway should do a renewal rather than a reissue. If not provided, default is 90.
* **CertType** - OPTIONAL: The type of cert to enroll for. Valid values are 'ssl' and 'client'. The value provided here must be consistant with the ProductID. If not provided, default is 'ssl'. Ignored for secure_email_* product types.
* **IncludeClientAuthEKU** - OPTIONAL for SSL certs, ignored otherwise. If set to 'true', SSL certs enrolled under this template will have the Client Authentication EKU added to the request. NOTE: This feature is currently planned to be removed by DigiCert in May 2026.
* **EnrollDivisionId** - OPTIONAL: The division (container) ID to use for enrollments against this template.
* **CommonNameIndicator** - Required for secure_email_sponsor and secure_email_organization products, ignored otherwise. Defines the source of the common name. Valid values are: email_address, given_name_surname, pseudonym, organization_name
* **ProfileType** - Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Default value is strict.
* **ProfileType** - Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Use 'multipurpose' if your cert includes any additional EKUs such as client auth. Default if not provided is dependent on product configuration within Digicert portal.
* **FirstName** - Required for secure_email_* types if CommonNameIndicator is given_name_surname, ignored otherwise.
* **LastName** - Required for secure_email_* types if CommonNameIndicator is given_name_surname, ignored otherwise.
* **Pseudonym** - Required for secure_email_* types if CommonNameIndicator is pseudonym, ignored otherwise.
Expand Down
3 changes: 3 additions & 0 deletions digicert-certcentral-caplugin/API/OrderCertificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public class CertificateRequest

[JsonProperty("ca_cert_id")]
public string CACertID { get; set; }

[JsonProperty("profile_option")]
public string ProfileOption { get; set; }
}

public class CertificateOrderContainer
Expand Down
51 changes: 41 additions & 10 deletions digicert-certcentral-caplugin/CertCentralCAPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar
string priorCertSnString = null;
string priorCertReqID = null;

if (typeOfCert.Equals("ssl") && Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH]))
{
orderRequest.Certificate.ProfileOption = "server_client_auth_eku";
_logger.LogWarning($"{CertCentralConstants.Config.INCLUDE_CLIENT_AUTH}: Ability to include client auth EKU in SSL certs is currently planned to cease in May 2026. Make sure any workflows that depend on this feature are updated before then to avoid interruptions.");
}

// Current gateway core leaves it up to the integration to determine if it is a renewal or a reissue
if (enrollmentType == EnrollmentType.RenewOrReissue)
{
Expand Down Expand Up @@ -584,6 +590,13 @@ public Dictionary<string, PropertyConfigInfo> GetTemplateParameterAnnotations()
DefaultValue = "ssl",
Type = "String"
},
[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH] = new PropertyConfigInfo()
{
Comments = "OPTIONAL for SSL certs, ignored otherwise. If set to 'true', SSL certs enrolled under this template will have the Client Authentication EKU added to the request. NOTE: This feature is currently planned to be removed by DigiCert in May 2026.",
Hidden = false,
DefaultValue = false,
Type = "Boolean"
},
[CertCentralConstants.Config.ENROLL_DIVISION_ID] = new PropertyConfigInfo()
{
Comments = "OPTIONAL: The division (container) ID to use for enrollments against this template.",
Expand All @@ -600,9 +613,9 @@ public Dictionary<string, PropertyConfigInfo> GetTemplateParameterAnnotations()
},
[CertCentralConstants.Config.PROFILE_TYPE] = new PropertyConfigInfo()
{
Comments = "Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Default value is strict.",
Comments = "Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Use 'multipurpose' if your cert includes any additional EKUs such as client auth. Default if not provided is dependent on product configuration within Digicert portal.",
Hidden = false,
DefaultValue = "strict",
DefaultValue = "",
Type = "String"
},
[CertCentralConstants.Config.FIRST_NAME] = new PropertyConfigInfo()
Expand Down Expand Up @@ -747,8 +760,14 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
{
_logger.MethodEntry(LogLevel.Trace);

lastSync = lastSync.HasValue ? lastSync.Value.AddHours(-7) : DateTime.MinValue; // DigiCert issue with treating the timezone as mountain time. -7 to accomodate DST
// DigiCert issue with treating the timezone as mountain time. -7 hours to accomodate DST
// If no last sync, use a 6 day window for the sync range (only relevant for incremental syncs)
lastSync = lastSync.HasValue ? lastSync.Value.AddHours(-7) : DateTime.UtcNow.AddDays(-5);
DateTime? utcDate = DateTime.UtcNow.AddDays(1);
if ((utcDate.Value - lastSync.Value).Days > 6)
{
lastSync = DateTime.UtcNow.AddDays(-5);
}
string lastSyncFormat = FormatSyncDate(lastSync);
string todaySyncFormat = FormatSyncDate(utcDate);

Expand Down Expand Up @@ -1023,7 +1042,7 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction
detailsRequest.ContainerId = null;
if (connectionInfo.ContainsKey(CertCentralConstants.Config.DIVISION_ID))
{
string div = (string)connectionInfo[CertCentralConstants.Config.DIVISION_ID];
string div = connectionInfo[CertCentralConstants.Config.DIVISION_ID].ToString();
if (!string.IsNullOrWhiteSpace(div))
{
if (int.TryParse($"{div}", out int divId))
Expand Down Expand Up @@ -1544,6 +1563,7 @@ private List<AnyCAPluginCertificate> GetAllConnectorCertsForOrder(string caReque
var orderCerts = GetAllCertsForOrder(orderId);

List<AnyCAPluginCertificate> certList = new List<AnyCAPluginCertificate>();
List<string> pemList = new List<string>();

foreach (var cert in orderCerts)
{
Expand All @@ -1565,6 +1585,13 @@ private List<AnyCAPluginCertificate> GetAllConnectorCertsForOrder(string caReque
throw new Exception($"Unexpected error downloading certificate {certId} for order {orderId}: {certificateChainResponse.Errors.FirstOrDefault()?.message}");
}
}
//Another check for duplicate PEMs to get arround issue with DigiCert API returning incorrect data sometimes on reissued/duplicate certs
if (pemList.Contains(certificate))
{
_logger.LogWarning($"Found duplicate PEM for ID {caReqId}. Skipping...");
continue;
}
pemList.Add(certificate);
var connCert = new AnyCAPluginCertificate
{
CARequestID = caReqId,
Expand Down Expand Up @@ -1680,9 +1707,10 @@ private EnrollmentResult EnrollForSmimeCert(string csr, string subject, Dictiona
}
}

string profile = null;
if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.PROFILE_TYPE))
{
string profile = productInfo.ProductParameters[CertCentralConstants.Config.PROFILE_TYPE].ToString();
profile = productInfo.ProductParameters[CertCentralConstants.Config.PROFILE_TYPE].ToString();

// Only validate if value provided
if (!string.IsNullOrEmpty(profile))
Expand All @@ -1693,6 +1721,10 @@ private EnrollmentResult EnrollForSmimeCert(string csr, string subject, Dictiona
throw new Exception($"Invalid profile type provided. Valid values are: strict, multipurpose");
}
}
else
{
profile = null;
}
}

if (cnIndic.Equals("given_name_surname", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -1884,12 +1916,11 @@ private EnrollmentResult EnrollForSmimeCert(string csr, string subject, Dictiona
orderRequest.Certificate.SignatureHash = certType.signatureAlgorithm;
orderRequest.Certificate.CACertID = caCertId;
orderRequest.SetOrganization(organizationId);
string profileType = "strict";
if (productInfo.ProductParameters.ContainsKey(Constants.Config.PROFILE_TYPE))
//If profile type is not provided, use the default on the digicert product configuration
if (!string.IsNullOrEmpty(profile))
{
profileType = productInfo.ProductParameters[Constants.Config.PROFILE_TYPE];
}
orderRequest.Certificate.ProfileType = profileType;
orderRequest.Certificate.ProfileType = profile;
}
orderRequest.Certificate.CommonNameIndicator = cnIndicator;
if (productInfo.ProductID.Equals("secure_email_sponsor", StringComparison.OrdinalIgnoreCase))
{
Expand Down
1 change: 1 addition & 0 deletions digicert-certcentral-caplugin/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Config
public const string FILTER_EXPIRED = "FilterExpiredOrders";
public const string SYNC_EXPIRATION_DAYS = "SyncExpirationDays";
public const string CERT_TYPE = "CertType";
public const string INCLUDE_CLIENT_AUTH = "IncludeClientAuthEKU";
public const string ENROLL_DIVISION_ID = "EnrollDivisionId";
public const string COMMON_NAME_INDICATOR = "CommonNameIndicator";
public const string PROFILE_TYPE = "ProfileType";
Expand Down
8 changes: 1 addition & 7 deletions digicert-certcentral-caplugin/Models/CertCentralCertType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class CertCentralCertType
#region Private Fields

private static readonly ILogger Logger = LogHandler.GetClassLogger<CertCentralCertType>();
private static List<CertCentralCertType> _allTypes;

#endregion Private Fields

Expand Down Expand Up @@ -62,12 +61,7 @@ public class CertCentralCertType
/// <returns></returns>
public static List<CertCentralCertType> GetAllTypes(CertCentralConfig config)
{
if (_allTypes == null || !_allTypes.Any())
{
_allTypes = RetrieveCertCentralCertTypes(config);
}

return _allTypes;
return RetrieveCertCentralCertTypes(config);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<RootNamespace>Keyfactor.Extensions.CAPlugin.DigiCert</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<AssemblyName>DigicertCAPlugin</AssemblyName>
<AssemblyVersion>2.1.2</AssemblyVersion>
<FileVersion>2.1.2</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion integration-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
"name": "CertType",
"description": "OPTIONAL: The type of cert to enroll for. Valid values are 'ssl' and 'client'. The value provided here must be consistant with the ProductID. If not provided, default is 'ssl'. Ignored for secure_email_* product types."
},
{
"name": "IncludeClientAuthEKU",
"description": "OPTIONAL for SSL certs, ignored otherwise. If set to 'true', SSL certs enrolled under this template will have the Client Authentication EKU added to the request. NOTE: This feature is currently planned to be removed by DigiCert in May 2026."
},
{
"name": "EnrollDivisionId",
"description": "OPTIONAL: The division (container) ID to use for enrollments against this template."
Expand All @@ -82,7 +86,7 @@
},
{
"name": "ProfileType",
"description": "Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Default value is strict."
"description": "Optional for secure_email_* types, ignored otherwise. Valid values are: strict, multipurpose. Use 'multipurpose' if your cert includes any additional EKUs such as client auth. Default if not provided is dependent on product configuration within Digicert portal."
},
{
"name": "FirstName",
Expand Down
Loading