如何从 C# 代码或在运行 IIS 的服务器上使用 Powershell 生成 IIS7 CSR(用于 SSL)
如何从 C# 生成服务器 SSL 证书签名请求 (CSR)?如果 PowerShell 是更好的选择,那也将是一个很好的解决方案。
How I can generate a server SSL Certificate Signing Request (CSR) from C#? If PowerShell is a better option, that would be a good solution as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一些常规提示:
编辑 - 根据评论:
COM对象
CertEnroll
由 MS 提供,可以通过 PowerShell 访问...Some general pointers:
EDIT - as per comments:
The COM object
CertEnroll
provided by MS can be accessed via PowerShell...我知道已经是三年后的事了,但 Yahia 解决方案中的链接表明它们不适用于 Server 2008。通过使用 PowerShell,我能够使用 Server 2008 附带的 Certreq.exe 来生成 CSR。 Certreq 的文档位于此处,以及 INF 文件的完整格式。当然,用您自己的值替换专有名称。这些字母对应于以下字段:
该脚本假定您有一个名为 TEMP 的环境变量,该变量指向您具有写入访问权限的目录
:对于 PowerShell 来说是新的,
@"
和"@
分隔符不得缩进。 (这些定义了所谓的“Here-String”...更多信息此处。)I know it's three years later, but the links in Yahia's solution state that they will not work for Server 2008. Using PowerShell, I was able to use Certreq.exe, which ships with Server 2008, to generate the CSR. The documentation for Certreq is here, along with the full format for the INF file. Of course, substitute your own values for the distinguished name. The letters correspond to these fields:
The script assumes you have an environment variable named TEMP that points to a directory for which you have write access:
For those who are new to PowerShell, the
@"
and"@
delimiters must not be indented. (These define what is known as a "Here-String"... more information here.)