2015-09-04 25 views
12

Próbuję użyć PowerShell, aby ustawić certyfikat SSL w witrynie IIS dla certyfikatu samopodpisanego/lokalnego.Powershell - Ustaw certyfikat SSL na https Binding

utworzyć certyfikat:

$newCert = 
     New-SelfSignedCertificate 
     -DnsName www.mywebsite.ru 
     -CertStoreLocation cert:\LocalMachine\My 

następnie spróbuj ustawić powiązania SSL:

get-item 
     cert:\LocalMachine\MY\$newCert.Thumbprint | 
     new-item -path IIS:\SslBindings\0.0.0.0!443 

jak pokazano na tym stanowisku: http://www.iis.net/learn/manage/powershell/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in

pokazano również tutaj: Powershell IIS7 Snap in Assign SSL certificate to https binding

Próbowałem również:

get-item 
     cert:\LocalMachine\MY\$newCert.Thumbprint | 
     new-item -path IIS:\SslBindings\*!443 

Na próżno nie widzę certyfikatu SSL ustawionego w oknie dialogowym Edytuj powiązanie serwisu.

Jakieś myśli?

+0

użyć 'IIS: \ SslBindings \ 0.0.0.0 443' zamiast' IIS : \ SslBindings \ *! 443'. Po powiązaniu witryny z tym portem zostanie użyty zarejestrowany certyfikat. –

Odpowiedz

17

Musisz przypisać certyfikat do strony , konkretnej pod adresem.

można pobrać informacje wiążący witryny przy użyciu Get-WebBinding komandletu i ustawić certyfikat SSL za pomocą AddSslCertificate funkcję:

$siteName = 'mywebsite' 
$dnsName = 'www.mywebsite.ru' 

# create the ssl certificate 
$newCert = New-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation cert:\LocalMachine\My 

# get the web binding of the site 
$binding = Get-WebBinding -Name $siteName -Protocol "https" 

# set the ssl certificate 
$binding.AddSslCertificate($newCert.GetCertHashString(), "my") 
Powiązane problemy