Cómo asignar un certificado SSL para IIS 7 Sitio desde Símbolo del sistema
-
09-09-2019 - |
Pregunta
¿Me puede aconsejar si es posible o no asignar un certificado SSL a un sitio web en IIS 7 mediante la aplicación appcmd?
Estoy familiarizado con el comando para establecer las HTTPS Encuadernación
appcmd set site /site.name:"A Site" /+bindings.[protocol='https',bindingInformation='*:443:www.mysite.com']
y cómo obtener las asignaciones actuales
%windir%\system32\inetsrv\Appcmd
pero parece que no puede encontrar ninguna manera de asignar un sitio a un certificado (decir el hash certificados por ejemplo)
Solución
La respuesta es utilizar NETSH. Por ejemplo
netsh http add sslcert ipport=0.0.0.0:443 certhash='baf9926b466e8565217b5e6287c97973dcd54874' appid='{ab3c58f7-8316-42e3-bc6e-771d4ce4b201}'
Otros consejos
Esto me ayudó mucho: una guía sencilla, por Sukesh Ashok Kumar, a la configuración de SSL para IIS desde la línea de comandos. Incluye la importación / de generar el certificado con certutil
/ makecert
.
http://www.awesomeideas.net/post/How-to-configure-SSL-on-IIS7-under-Windows-2008-Server-Core.aspx
EDIT: si la URL original se ha reducido, sigue siendo disponible a través de la Wayback Machine .
Con PowerShell y el módulo WebAdministration, puede hacer lo siguiente para asignar un certificado SSL para un sitio de IIS:
# ensure you have the IIS module imported
Import-Module WebAdministration
cd IIS:\SslBindings
Get-Item cert:\LocalMachine\My\7ABF581E134280162AFFFC81E62011787B3B19B5 | New-Item 0.0.0.0!443
A tener en cuenta ... el valor, "7ABF581E134280162AFFFC81E62011787B3B19B5" es la huella digital del certificado que desea importar. Por lo que debe ser importado en el almacén de certificados en primer lugar. El cmdlet New-Item
toma la dirección IP (0.0.0.0 para todos los IPs) y el puerto.
:. //learn.iis.net/page.aspx/491/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in/ para más detalles
He probado esto en Windows Server 2008 R2, así como Windows Server 2012 pre-lanzamiento.
@ David y @orip tenerlo derecha.
Sin embargo, me gustaría mencionar que el ipport parámetro especificado en el ejemplo (0.0.0.0:443) es lo que el MSDN llama la "dirección no especificada (IPv4: 0.0.0.0 o IPv6: [::])".
Fui mirar hacia arriba, por lo que pensé en documentos aquí para salvar a otra persona el tiempo. Este artículo se centra en SQL Server, pero la información sigue siendo pertinente:
Uso de las respuestas de esta entrada, he creado un script único que hizo el truco para mí. Se inicia desde el archivo PFX, pero se puede saltarse este paso.
Aquí está:
cd C:\Windows\System32\inetsrv
certutil -f -p "pa$$word" -importpfx "C:\temp\mycert.pfx"
REM The thumbprint is gained by installing the certificate, going to cert manager > personal, clicking on it, then getting the Thumbprint.
REM Be careful copying the thumbprint. It can add hidden characters, esp at the front.
REM appid can be any valid guid
netsh http add sslcert ipport=0.0.0.0:443 certhash=5de934dc39cme0234098234098dd111111111115 appid={75B2A5EC-5FD8-4B89-A29F-E5D038D5E289}
REM bind to all ip's with no domain. There are plenty of examples with domain binding on the web
appcmd set site "Default Web Site" /+bindings.[protocol='https',bindingInformation='*:443:']