To learn about obtaining server certificates, see Obtaining a Server Certificate.
Suppose you are managing a multiple-server network. To acquire SSL server certificates and install and implement copies of the certificates on all the servers requires the following steps.
Using WSH on IIS 6.0, you can execute scripts to communicate with IISCertObj, programmatically importing, archiving, and exporting certificates.
Suppose you needed to use SSL for secure user logon to 100 or more servers. Further, you require all of the servers to use copies of the same SSL certificate. It would be awkward and very time-consuming to use the MMC snap-in to add these copies to each server. What you need is a scripted solution that installs copies of the same certificate to the entire server farm.
Save the following script as Certimport.vbs. Modify the command-line statement arguments to match your network resources. Then use the command-line statement to import a certificate from a certificate store on one server to other servers that require it.
Sample script (Certimport.vbs):
dim iiscertobjCommand line statement:
Certimport.vbs cert.pfx pfxpwd101 1 iisserver1,iisserver2,iisserver3Suppose you are managing a server farm with many different SSL certificates. Using the IISCertObj export method, you can archive a backup of each certificate on your server farm to a central site.
Save the following script as Save_all_certs.vbs in your text editor. Modify the command-line statement arguments to match your network resources. Then use the command-line statement to export copies of certificates to the central site.
Sample script (Save_all_certs.vbs):
dim iiscertobj, targetServer, targetServers, pfxbasenameCommand line statement:
Save_all_certs.vbs certbackup adsf-0324 1 iisserver2,iisserver3,iisserver4Suppose you add a server to your server farm, install Windows Server and IIS. The script and command-line statement below will allow you to use the copy method of IISCertObj to copy a certificate to the new server. Save the script below as certcopy.vbs. Modify the command-line statement arguments to match your network resources. Then run the command-line statement.
Sample script (certcopy.vbs):
dim iiscertobj, targetServer, targetServers, targetInstanceCommand line statement:
Certcopy.vbs iisServer1 1 iisServer2 1 Administrator asdf-0324This section lists the IISCertObj properties and methods supported in IIS 6.0.
Properties should be set before calling methods. Methods will return an error message if the required properties for that method are not available when the method is called.
The following properties are used to generate certificate requests.
ServerName ServerName is the name of the computer on which the certificate operations are executed.
HRESULT ServerName ([in] BSTR newVal);
UserName The UserName property allows you to specify the username used for logon to the remote machine. If UserName is empty, the credentials of the currently logged on user are used. To install a certificate into a remote certificate store, the user must have administrator privileges on the remote machine.
HRESULT UserName ([in] BSTR newVal);
UserPassword The UserPassword property allows you to specify the password used for logon to the remote machine.
HRESULT UserPassword ([in] BSTR newVal);
InstanceName Identifies the targeted instance of IIS.
HRESULT InstanceName ([in] BSTR newVal);
Export The Export method exports a copy of a certificate to a file. The target file may be on the local computer or on a remote computer.
HRESULT Export(BSTR FileName, BSTR Password, BSTR Password, _
BOOL bPrivateKey, BOOL bCertChain, BOOL bRemoveCert);
The Export method requires the following parameters:
Move The Move method allows you to move a certificate from one instance of IIS to another, and from from one computer to another.
HRESULT Import(BSTR DestinationServerName, BSTR DestinationServerInstance, _
[optional] BSTR DestinationServer UserName, _
[optional] BSTR DestinationServer Password);
The Move method uses the following parameters:
Copy The Copy method allows you to copy a certificate from one instance of IIS to another, and from one computer to another.
HRESULT Copy(BSTR DestinationServerName, BSTR DestinationServerInstance, _
[optional] BSTR DestinationServer UserName, _
[optional] BSTR DestinationServer Password);
The Copy method uses the following parameters:
IsInstalled The IsInstalled allows you to determine whether or not a certificate is installed on a computer specified by the ServerName property.
HRESULT IsInstalled(BSTR InstanceName, VARIANT_BOOL * retval)
The IsInstalled method uses the following parameters: