Skip to content

Commit 0ca0beb

Browse files
committed
add option for kdc/smartcardlogon eku, fix template validation
1 parent 56f8d13 commit 0ca0beb

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

digicert-certcentral-caplugin/CertCentralCAPlugin.cs

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,23 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar
295295
string priorCertSnString = null;
296296
string priorCertReqID = null;
297297

298-
if (typeOfCert.Equals("ssl") && Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH]))
298+
if (typeOfCert.Equals("ssl"))
299299
{
300-
orderRequest.Certificate.ProfileOption = "server_client_auth_eku";
301-
_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.");
300+
bool clientAuth = Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH]);
301+
bool kdc = Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_KDC]);
302+
if (clientAuth && kdc)
303+
{
304+
throw new Exception($"Cannot enroll for cert with both Client Auth and KDC/SmartCardLogon EKU set to 'true'");
305+
}
306+
if (clientAuth)
307+
{
308+
orderRequest.Certificate.ProfileOption = "server_client_auth_eku";
309+
_logger.LogWarning($"{CertCentralConstants.Config.INCLUDE_CLIENT_AUTH}: Ability to include client auth EKU in SSL certs is currently planned to cease in March 2027. Make sure any workflows that depend on this feature are updated before then to avoid interruptions.");
310+
}
311+
else if (kdc)
312+
{
313+
orderRequest.Certificate.ProfileOption = "kdc_smart_card";
314+
}
302315
}
303316

304317
bool dupe = false;
@@ -616,7 +629,14 @@ public Dictionary<string, PropertyConfigInfo> GetTemplateParameterAnnotations()
616629
},
617630
[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH] = new PropertyConfigInfo()
618631
{
619-
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.",
632+
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 March 2027.",
633+
Hidden = false,
634+
DefaultValue = false,
635+
Type = "Boolean"
636+
},
637+
[CertCentralConstants.Config.INCLUDE_KDC] = new PropertyConfigInfo()
638+
{
639+
Comments = "OPTIONAL for SSL certs, ignored otherwise. If set to 'true', SSL certs enrolled under this template will have the KDC/SmartCardLogon EKU added to the request.",
620640
Hidden = false,
621641
DefaultValue = false,
622642
Type = "Boolean"
@@ -1064,9 +1084,9 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction
10641084
CertificateTypeDetailsRequest detailsRequest = new CertificateTypeDetailsRequest(product.NameId);
10651085

10661086
detailsRequest.ContainerId = null;
1067-
if (connectionInfo.ContainsKey(CertCentralConstants.Config.DIVISION_ID))
1087+
if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.ENROLL_DIVISION_ID))
10681088
{
1069-
string div = connectionInfo[CertCentralConstants.Config.DIVISION_ID].ToString();
1089+
string div = productInfo.ProductParameters[CertCentralConstants.Config.ENROLL_DIVISION_ID].ToString();
10701090
if (!string.IsNullOrWhiteSpace(div))
10711091
{
10721092
if (int.TryParse($"{div}", out int divId))
@@ -1088,15 +1108,30 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction
10881108

10891109
if (!Constants.ProductTypes.SMIME_CERT.Contains(productInfo.ProductID, StringComparer.OrdinalIgnoreCase))
10901110
{
1091-
if (connectionInfo.ContainsKey(CertCentralConstants.Config.CERT_TYPE))
1111+
if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.CERT_TYPE))
10921112
{
1093-
var typeOfCert = (string)connectionInfo[CertCentralConstants.Config.CERT_TYPE];
1113+
var typeOfCert = (string)productInfo.ProductParameters[CertCentralConstants.Config.CERT_TYPE];
10941114
if (!(typeOfCert.Equals("ssl") || typeOfCert.Equals("client")))
10951115
{
10961116
throw new AnyCAValidationException("Invalid Cert Type specified. Valid options are 'ssl' or 'client'");
10971117
}
10981118
}
10991119
}
1120+
1121+
bool clientAuth = false, kdc = false;
1122+
if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.INCLUDE_CLIENT_AUTH))
1123+
{
1124+
clientAuth = Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH]);
1125+
}
1126+
if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.INCLUDE_KDC))
1127+
{
1128+
kdc = Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_KDC]);
1129+
}
1130+
if (clientAuth && kdc)
1131+
{
1132+
throw new AnyCAValidationException($"Unable to use both {CertCentralConstants.Config.INCLUDE_CLIENT_AUTH} and {CertCentralConstants.Config.INCLUDE_KDC} in the same certificate.");
1133+
}
1134+
11001135
_logger.MethodExit(LogLevel.Trace);
11011136
}
11021137

digicert-certcentral-caplugin/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Config
3434
public const string SYNC_EXPIRATION_DAYS = "SyncExpirationDays";
3535
public const string CERT_TYPE = "CertType";
3636
public const string INCLUDE_CLIENT_AUTH = "IncludeClientAuthEKU";
37+
public const string INCLUDE_KDC = "IncludeKDCSmartCardLogonEKU";
3738
public const string ENROLL_DIVISION_ID = "EnrollDivisionId";
3839
public const string COMMON_NAME_INDICATOR = "CommonNameIndicator";
3940
public const string PROFILE_TYPE = "ProfileType";

0 commit comments

Comments
 (0)