Skip to content

Commit 1a2a31c

Browse files
Restore binding deployment on linux, if target selected/present.
1 parent 1e85de1 commit 1a2a31c

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

src/Certify.Core/Management/BindingDeploymentManager.cs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Runtime.InteropServices;
54
using System.Security.Cryptography.X509Certificates;
65
using System.Threading.Tasks;
76
using Certify.Management;
@@ -55,12 +54,6 @@ public async Task<List<ActionStep>> StoreAndDeploy(IBindingDeploymentTarget depl
5554
{
5655
var actions = new List<ActionStep>();
5756

58-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
59-
{
60-
actions.Add(new ActionStep { Title = "Certificate Store and Deploy Skipped", Category = "CertificateStorage", Description = "Platform not supported for certificate store, skipping" });
61-
return actions;
62-
}
63-
6457
var requestConfig = managedCertificate.RequestConfig;
6558

6659
if (!isPreviewOnly)
@@ -116,28 +109,32 @@ public async Task<List<ActionStep>> StoreAndDeploy(IBindingDeploymentTarget depl
116109

117110
if (storedCert != null)
118111
{
119-
//get list of domains we need to create/update https bindings for
120-
var dnsHosts = new List<string> {
121-
requestConfig.PrimaryDomain
122-
};
123-
124-
if (requestConfig.SubjectAlternativeNames != null)
112+
// if a deployment target is available (IIS, nginx etc) we will attempt to deploy the cert to the target
113+
if (deploymentTarget != null)
125114
{
126-
foreach (var san in requestConfig.SubjectAlternativeNames)
115+
//get list of domains we need to create/update https bindings for
116+
var dnsHosts = new List<string> {
117+
requestConfig.PrimaryDomain
118+
};
119+
120+
if (requestConfig.SubjectAlternativeNames != null)
127121
{
128-
dnsHosts.Add(san);
122+
foreach (var san in requestConfig.SubjectAlternativeNames)
123+
{
124+
dnsHosts.Add(san);
125+
}
129126
}
130-
}
131127

132-
dnsHosts = dnsHosts
133-
.Distinct()
134-
.Where(d => !string.IsNullOrEmpty(d))
135-
.ToList();
128+
dnsHosts = dnsHosts
129+
.Distinct()
130+
.Where(d => !string.IsNullOrEmpty(d))
131+
.ToList();
136132

137-
// depending on our deployment mode we decide which sites/bindings to update:
138-
var deployments = await DeployToAllTargetBindings(deploymentTarget, managedCertificate, requestConfig, certStoreName, certHash, dnsHosts, isPreviewOnly);
133+
// depending on our deployment mode we decide which sites/bindings to update:
134+
var deployments = await DeployToAllTargetBindings(deploymentTarget, managedCertificate, requestConfig, certStoreName, certHash, dnsHosts, isPreviewOnly);
139135

140-
actions.AddRange(deployments);
136+
actions.AddRange(deployments);
137+
}
141138
}
142139
else
143140
{

src/Certify.Core/Management/Servers/ServerProviderIIS.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ public void Init(ILog log, string configRoot = null)
4444
private IISBindingDeploymentTarget _iisBindingDeploymentTarget = null;
4545
public IBindingDeploymentTarget GetDeploymentTarget()
4646
{
47-
if (_iisBindingDeploymentTarget == null)
47+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
4848
{
49-
_iisBindingDeploymentTarget = new IISBindingDeploymentTarget(this);
50-
}
49+
if (_iisBindingDeploymentTarget == null)
50+
{
51+
_iisBindingDeploymentTarget = new IISBindingDeploymentTarget(this);
52+
}
5153

52-
return _iisBindingDeploymentTarget;
54+
return _iisBindingDeploymentTarget;
55+
}
56+
else
57+
{
58+
return null;
59+
}
5360
}
5461

5562
public Task<bool> IsAvailable()

0 commit comments

Comments
 (0)