diff --git a/CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs b/CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs index c55e8c5..630473e 100644 --- a/CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs +++ b/CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs @@ -515,6 +515,27 @@ private string GenerateKeyPairName(string alias) return alias; } + public void BindServices(string alias, string serviceNames, string serviceSniCerts) + { + string[] serviceNameList = serviceNames.Split(','); + string[] serviceSniCertList = serviceSniCerts.Split(','); + + if (serviceNameList.Length != serviceSniCertList.Length) + throw new Exception("Number of Service Names must match number of SNI Services"); + + for (int i = 0; i < serviceNameList.Length; i++) + { + sslservice_sslcertkey_binding binding = new sslservice_sslcertkey_binding() + { + certkeyname = alias, + servicename = serviceNameList[i], + snicert = Convert.ToBoolean(serviceSniCertList[i]) + }; + + sslservice_sslcertkey_binding.add(_nss, binding); + }; + } + public void UpdateBindings(string keyPairName, string virtualServerName, string sniCert) { try diff --git a/CitrixAdcOrchestratorJobExtension/Management.cs b/CitrixAdcOrchestratorJobExtension/Management.cs index 247bafb..bcdf090 100644 --- a/CitrixAdcOrchestratorJobExtension/Management.cs +++ b/CitrixAdcOrchestratorJobExtension/Management.cs @@ -22,6 +22,8 @@ using System.IO; using static Org.BouncyCastle.Math.EC.ECCurve; using com.citrix.netscaler.nitro.resource.config.pq; +using com.citrix.netscaler.nitro.resource.config.ssl; +using com.citrix.netscaler.nitro.service; namespace Keyfactor.Extensions.Orchestrator.CitricAdc { @@ -144,6 +146,8 @@ private JobResult ProcessJob(CitrixAdcStore store, ManagementJobConfiguration jo _logger.LogDebug("Begin Add..."); var virtualServerName = (string)jobConfiguration.JobProperties["virtualServerName"]; var sniCert = (string)jobConfiguration.JobProperties["sniCert"]; + var serviceName = (string)jobConfiguration.JobProperties["serviceName"]; + var serviceSniCert = (string)jobConfiguration.JobProperties["serviceSniCert"]; dynamic properties = JsonConvert.DeserializeObject(jobConfiguration.CertificateStoreDetails.Properties.ToString()); var linkToIssuer = properties.linkToIssuer == null || string.IsNullOrEmpty(properties.linkToIssuer.Value) ? false : Convert.ToBoolean(properties.linkToIssuer.Value); @@ -165,6 +169,11 @@ private JobResult ProcessJob(CitrixAdcStore store, ManagementJobConfiguration jo PerformAdd(store, jobConfiguration.JobCertificate, keyPairName, virtualServerName, jobConfiguration.Overwrite, sniCert, linkToIssuer); _logger.LogDebug("End Add/Enrollment..."); + + if (!string.IsNullOrEmpty(serviceName)) + { + store.BindServices(jobConfiguration.JobCertificate.Alias, serviceName, serviceSniCert); + } } else {