How to assign a SSL Certificate to IIS7 Site from Command Prompt

前端 未结 7 1004
执笔经年
执笔经年 2020-12-04 12:52

Can you advise me whether it is possible or not to assign a SSL Certificate to a website in IIS7 using the APPCMD application?

I am familiar with the command to set

7条回答
  •  爱一瞬间的悲伤
    2020-12-04 13:40

    With PowerShell and the WebAdministration module, you can do the following to assign an SSL certificate to an IIS site:

    # 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
    

    Things to note... the value, "7ABF581E134280162AFFFC81E62011787B3B19B5" is the thumbprint for the certificate you want to import. So it needs to be imported into the certificate store first. The New-Item cmdlet takes in the IP address (0.0.0.0 for all IPs) and the port.

    See http://learn.iis.net/page.aspx/491/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in/ for more details.

    I've tested this in Windows Server 2008 R2 as well as Windows Server 2012 pre-release.

提交回复
热议问题