Getting error
"SSL Certificate add failed, Error: 1312 A specified logon session does not exist. It may already have been terminated"
windows_certificate "C:/tmp/cert/certpfx.pfx" do
pfx_password "12345"
user_store false
end
windows_certificate_binding 'Binding' do
action :create
name 'CN=www.demo.com'
name_kind :subject
store_name "MY"
port 443
address '0.0.0.0'
end
After googling find that this is not working due to "Allow Export " is not setting true while import certificate
I can able to install same certificate manually with allow export true
Please help how to resolve this.
also same thing working fine using powershell script
powershell_script 'Cert_install' do
code <<-EOH
$securePWD = ConvertTo-SecureString "#{node.run_state['path_values']['certpwd']}" -AsPlainText -Force
Import-PfxCertificate -FilePath "#{node['br_ics_ppi_app_app']['cert']}/pfx.txt" -CertStoreLocation cert:\LocalMachine\My -Password securePWD
Import-Certificate -FilePath "#{node['br_ics_ppi_app_app']['cert']}/certchain.txt" -CertStoreLocation Cert:\LocalMachine\CA
Import-Certificate -FilePath "#{node['br_ics_ppi_app_app']['cert']}/certroot.txt" -CertStoreLocation Cert:\LocalMachine\Root
& {iisreset}
EOH
notifies :run, 'powershell_script[add_cert_website]', :immediately
not_if "[bool](dir cert:\LocalMachine\My | ? { .subject -like ' #{node.run_state['path_values']['r53privzone']} '})"
end
powershell_script 'add_cert_website' do
code <<-EOH
$cert_name = "#{node.run_state['path_values']['r53privzone']}"
$cert_name = " " + $cert_name.Trimend('.') + " "
$ssl_web_site_name = "#{node['br_ics_ppi_app_app']['site_name']}"
$hostname = "#{node.run_state['path_values']['r53privzone']}"
$hostname = $cert_name.Trimend('.')
$ssl_web_site_port = 443
$guid_value = [GUID]::NewGUID().ToString('B')
$cert_thumb = $null
cert_thumb = (Get-ChildItem cert:\LocalMachine\My | where-object { .Subject -like $cert_name } | Select-Object -First 1).Thumbprint
Get-WebBinding -Port $ssl_web_site_port -Name "$ssl_web_site_name" | Remove-WebBinding
New-WebBinding -Name "$ssl_web_site_name" -IP "*" -Port $ssl_web_site_port -Protocol https
netsh http show sslcert ipport=0.0.0.0:$ssl_web_site_port
if ($LASTEXITCODE -eq 1) {
netsh http add sslcert ipport=0.0.0.0:$ssl_web_site_port certhash=$cert_thumb appid=$guid_value
}
Import-Module WebAdministration
Stop-WebSite $ssl_web_site_name
Start-WebSite $ssl_web_site_name
EOH
action :nothing
end