IIS6:从命令行创建/安装 SSL 自签名证书

发布于 2024-11-30 01:53:29 字数 226 浏览 1 评论 0原文

我想在 IIS6 中自动为网站设置 SSL。似乎可以使用 selfSSL 和 certutil 来执行此操作,但证书对我来说是新的,我不确定如何将它们组合在一起。

据我了解,我需要:

  1. 创建证书
  2. 将证书分配给网站
  3. 添加安全(SSL/443)绑定到网站

如果已经创建了站点证书,我还想避免创建新证书。这样我就不会得到一堆多余的证书。

I want to automate the setup of SSL for a website in IIS6. It appears selfSSL and certutil can be used to do this but certificates are new to me and I'm unsure how to put them together.

From what I understand I need to:

  1. create a certificate
  2. assign the certificate to the website
  3. add a secure (SSL/443) binding to the website

I would also like to avoid creating a new certificate if the site cert has already been created. That way I don't end up with a bunch of redudant certs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静若繁花 2024-12-07 01:53:29

我建议您查看 IIS 6 资源工具包:http ://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17275

资源工具包中有一个名为selfssl.exe - 它自动创建、分配甚至信任新创建的证书。我们在工作中经常使用它,以确保我们的开发盒拥有可以在测试/开发期间使用的证书。

这是我们使用的命令行 - 它将使用密钥大小 1024 创建证书(针对本地主机),信任它,并使其有效期约 10 年:

selfssl.exe /T /N:CN=localhost /K:1024 /V:3650

如果您托管多个站点,则需要使用/S 参数指定要添加证书的站点 ID。

注意:这在 WinXP 上的 IIS 5 上也能正常工作,但我从未在任何 IIS 7 系列上尝试过。

I would suggest you look at the IIS 6 Resource Kit: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17275

There is a tool in the resource kit called selfssl.exe - it automates the creation, assignment and even trusting of the newly created certificate. We use it quite a bit where I work to ensure that our dev boxes have certificates we can use during testing/development.

Here is the command line we use - it will create the cert (for localhost) using a key-size of 1024, trust it, and make it valid for ~10 years:

selfssl.exe /T /N:CN=localhost /K:1024 /V:3650

If you are hosting multiple sites, you will need to use the /S parameter to specify the site id you want to add the certificate to.

Note: this also works like a champ with IIS 5 on WinXP, but I have never tried it on any of the IIS 7 family.

溇涏 2024-12-07 01:53:29

如果您使用 Wix 来创作您的设置,则运行此 CustomAction (仅运行 SelfSSL)将为您解决问题:

<CustomAction Id="InstallCert" 
              ExeCommand="selfssl.exe /N:CN=fqdn.myserver.com /V:365" /> 

<InstallExecuteSequence> 
    <Custom Action="InstallCert" After="InstallFinalize" /> 
</InstallExecuteSequence> 

此操作将

  • 生成证书
  • 将证书安装到默认网站
  • 添加 https 绑定

命令行说明:

/N:CN=[fully qualified server name]
/V: = Validity in days (365 in my example)

您可以使用 指定端口>/P:[端口号]开关。默认值为 443,这是您想要的,因此您可以将其省略。

警告:SelfSSL 似乎存在错误,该错误似乎已已解决

如果您仍然遇到它,替代方法是切换到具有类似语法的 SSLDiag 工具:

SSLDiag.exe /selfssl /n:CN=fqdn.myserver.com /v:365

我没有使用其他安装创作工具(InstallShield 等)的经验,但我确信他们有规定运行命令行程序。最坏的情况,您可以通过批处理文件运行它!

希望这有帮助。

If you're using Wix for authoring your setup, then running this CustomAction (which simply runs SelfSSL) will do the trick for you:

<CustomAction Id="InstallCert" 
              ExeCommand="selfssl.exe /N:CN=fqdn.myserver.com /V:365" /> 

<InstallExecuteSequence> 
    <Custom Action="InstallCert" After="InstallFinalize" /> 
</InstallExecuteSequence> 

This action will:

  • Generate the certificate
  • Install the certificate to Default Web Site
  • Add the https binding

Command line explained:

/N:CN=[fully qualified server name]
/V: = Validity in days (365 in my example)

You can specify port with /P:[port number] switch. The default is 443 which is what you want so you can leave it out.

Caveat: There seems to be bug with SelfSSL which seems to have been resolved.

If you still run into it, alternative is to switch to SSLDiag tool which has a similar syntax:

SSLDiag.exe /selfssl /n:CN=fqdn.myserver.com /v:365

I do not have experience with other setup authoring tools (InstallShield etc.) but I'm sure they have provisions to run commandline programs. Worst case, you can run this through a batch file!

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文