Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,20 @@ function Add-SslCert
[string]$hostname,
[string]$sni,
[int]$iisVersion,
[string]$ipAddress
[string]$ipAddress,
[string]$certstore
)

if([string]::IsNullOrWhiteSpace($certhash))
{
Write-Verbose "CertHash is empty. Returning"
return
}
if([string]::IsNullOrWhiteSpace($certstore))
{
Write-Verbose "CertStore is empty. Setting it to MY"
$certstore = "MY"
}

if($ipAddress -eq "All Unassigned" -or $ipAddress -eq "*")
{
Expand All @@ -185,7 +191,7 @@ function Add-SslCert
$result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd
$isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $hostname, $port))

$addCertCmd = [string]::Format("http add sslcert hostnameport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $hostname, $port, $certhash, [System.Guid]::NewGuid().toString())
$addCertCmd = [string]::Format("http add sslcert hostnameport={0}:{1} certhash={2} appid={{{3}}} certstorename={4}", $hostname, $port, $certhash, [System.Guid]::NewGuid().toString(), $certstore)
}
else
{
Expand All @@ -195,7 +201,7 @@ function Add-SslCert
$result = Invoke-VstsTool -Filename "netsh" -Arguments $showCertCmd
$isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $ipAddress, $port))

$addCertCmd = [string]::Format("http add sslcert ipport={0}:{1} certhash={2} appid={{{3}}} certstorename=MY", $ipAddress, $port, $certhash, [System.Guid]::NewGuid().toString())
$addCertCmd = [string]::Format("http add sslcert ipport={0}:{1} certhash={2} appid={{{3}}} certstorename={4}", $ipAddress, $port, $certhash, [System.Guid]::NewGuid().toString(), $certstore)
}

$isItSameCert = $result.Get(5).ToLower().Contains($certhash.ToLower())
Expand Down Expand Up @@ -287,7 +293,7 @@ function Add-WebsiteBindings {
}

if($binding.protocol -eq "https") {
Add-SslCert -ipAddress $binding.ipAddress -port $binding.port -certhash $binding.sslThumbPrint -hostname $binding.hostName -sni $binding.sniFlag -iisVersion $iisVersion
Add-SslCert -ipAddress $binding.ipAddress -port $binding.port -certhash $binding.sslThumbPrint -hostname $binding.hostName -sni $binding.sniFlag -iisVersion $iisVersion -certstore $binding.certStore
Enable-SNI -siteName $siteName -sni $binding.sniFlag -ipAddress $binding.ipAddress -port $binding.port -hostname $binding.hostName
}
}
Expand Down