Bind ssl certificate to https in IIS

453 Views Asked by At

I have a valid pfx certificate, our support colleagues have to import certificate and select it for https binding manually per server....

I am trying to make this process automatically so I am using install shield for installing my packs.

I am using below command to add https binding:

set site /site.name: mySite /+bindings.[protocol='https',bindingInformation='*:443:']"

and this for importing certificate to IIS:

C:\Windows\System32\inetsrv>certutil -f -p "myPass"  -importpfx "e:\folder\x.pfx"

now I want to add that certificate to https binding as below :

C:\Windows\System32\inetsrv>netsh http add sslcert ipport=*:443 certhash='certificate hash code' appid='my application id'

I crossed with below error:

The parameter is incorrect.

at the end my install script is:

function LONG SetSiteSettings(hMSI)   
    STRING svDir; 
    STRING certificateDir; 
    LONG ret;
begin             

    svDir = WINDIR ^ "system32\\inetsrv\\APPCMD.exe"; 
    ret = LaunchAppAndWait(svDir, "set site /site.name: marcoweb /+bindings.[protocol='https',bindingInformation='*:443:']", WAIT); 
    if (ret != 0) then return ret; endif;

    certificateDir= INSTALLDIR ^ "marcoweb\\x.pfx";   
    ret =  LaunchAppAndWait(svDir, "certutil -f -p "myPass"  -importpfx \"" + certificateDir + "\"", WAIT);
    if (ret != 0) then return ret; endif;

    ret = LaunchAppAndWait(svDir, "netsh http add sslcert ipport=*:443 certhash='certificate hash code' appid='app id per install!!!'", WAIT);
    if (ret != 0) then return ret; endif; 
    return 0;
end;  

but :

1-How can I know application id per install or how it can be defined for https without appid parameter?

2-Is there another solutions to do this?

0

There are 0 best solutions below