From da0a08c6aa3de22beb033555f1fce22b10ebe00b Mon Sep 17 00:00:00 2001 From: stack72 Date: Tue, 22 Apr 2014 13:16:09 +0100 Subject: [PATCH] Fixing the onlyif statement as well as the erb template for creating the certificate binding --- manifests/manage_binding.pp | 2 +- templates/create-certificate-binding.ps1.erb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/manage_binding.pp b/manifests/manage_binding.pp index 9baeba0..ffb2bc8 100644 --- a/manifests/manage_binding.pp +++ b/manifests/manage_binding.pp @@ -42,7 +42,7 @@ exec { "Attach-Certificate-${title}": command => "C:\\temp\\create-${name}.ps1", - onlfif => "C:\\temp\\inspect-${name}.ps1", + onlyif => "C:\\temp\\inspect-${name}.ps1", require => [File["inspect-${title}-certificate.ps1"], File["create-${title}-certificate.ps1"]], provider => powershell, logoutput => true, diff --git a/templates/create-certificate-binding.ps1.erb b/templates/create-certificate-binding.ps1.erb index 64dc764..551e177 100644 --- a/templates/create-certificate-binding.ps1.erb +++ b/templates/create-certificate-binding.ps1.erb @@ -4,11 +4,11 @@ $site = Get-Website | Where-Object { $_.Name -eq "<%= site_name %>" } $certsAttachedToSite = Get-ChildItem IIS:\SSLBindings | ? { $site | Select-Object { $_ -contains $_.Sites.Value }} | % { $_.Thumbprint } $certificate = Get-ChildItem CERT:\LocalMachine\My | ? { $certsAttachedToSite -contains $_.Thumbprint} | Where-Object { $_.Thumbprint -eq "<%= certificate_thumbprint %>" } -if((Test-Path IIS:\SslBindings\$ip!$port) -eq $false) { +if((Test-Path IIS:\SslBindings\<%= ip_address %>!<%= port %>) -eq $false) { push-location IIS:\SslBindings - Get-Item Cert:\LocalMachine\My\<%= certificate_thumbprint %> | New-Item <%= ip_address %>!443 + Get-Item Cert:\LocalMachine\My\<%= certificate_thumbprint %> | New-Item <%= ip_address %>!<%= port %> } -elseif (((Test-Path IIS:\SslBindings\$ip!$port) -eq $true) -and (($certificate -ne $null) -or ($certificate.Thumbprint -ne <%= certificate_thumbprint %>))) { +elseif (((Test-Path IIS:\SslBindings\<%= ip_address %>!<%= port %>) -eq $true) -and (($certificate -ne $null) -or ($certificate.Thumbprint -ne "<%= certificate_thumbprint %>"))) { push-location IIS:\SslBindings Get-Item Cert:\LocalMachine\My\<%= certificate_thumbprint %> | Set-Item <%= ip_address %>!<%= port %> foreach ($cert in $certificates) {