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

前端 未结 7 1011
执笔经年
执笔经年 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:30

    Using PowerShell + netsh:

    $certificateName = 'example.com'
    $thumbprint = Get-ChildItem -path cert:\LocalMachine\My | where { $_.Subject.StartsWith("CN=$certificateName") } | Select-Object -Expand Thumbprint
    $guid = [guid]::NewGuid().ToString("B")
    netsh http add sslcert ipport="0.0.0.0:443" certhash=$thumbprint certstorename=MY appid="$guid"
    

    If you need a named binding, replace netsh call with this:

    netsh http add sslcert hostnameport="$certificateName:443" certhash=$thumbprint certstorename=MY appid="$guid"
    

提交回复
热议问题