Windows PKI:我如何导入,签署/发布和导出大量的CSR?

我有很多CSR需要在Windows上签名/发布和导出。 我希望能够以某种方式对它们进行批量处理(虽然听起来像是可以做一些工作),但我不太确定如何去做这件事。 这可行吗?

任何帮助将不胜感激。

检查公钥基础结构PowerShell模块 。 Approve-CertificateRequest和Receive-Certificate命令可以帮助你。

我可以说是的,这是可行的。 但是,这将是一个很好的工作,我怀疑互联网上的免费问答网站上的任何人都会自愿为您做所有这些免费的系统pipe理工作……至less可以让您开始。

有两种主要的方法来解决这个问题。 其中一个,就像你已经确定的那样,是certutil。 您可能会使用Powershell为certutil.exe编写一个“包装器”,为它提供input并分析其输出。

其次,证书服务COM组件CERTENROLLib,CERTCLIENTLib等。这些允许你脚本的任何和所有的工作,否则将手动,只要你愿意把它脚本的努力。

看, 这个人正在使用C#和前面提到的COM接口创build一个CSR,将CSR提交给证书颁发机构,并获得响应并安装证书。 C#很容易移植到Powershell。

其次,certutil …你可以用certutil来做大部分事情,但是它不是面向对象的,而是所有的文本parsing,像旧世界的Unix东西。 举例来说,我将与您分享一个我使用certutil扫描证书颁发机构上的挂起证书请求的简短Powershell脚本,并在pipe理员有任何待审批的CSR需要批准时通知pipe理员。

[String]$CAName = 'SERVER01\MY-ISSUING-CA' [String]$MailFrom = '[email protected]' [String[]]$MailTo = '[email protected]' [String]$SMTPServer = 'smtp.domain.com' $Output = certutil -view -out "Request ID, Request Submission Date, Request Common Name, Requester Name, Request Email Address, Request Distinguished Name" -Restrict "Request Disposition=9" If ($Output[-1] -NotLike '*successfully.') { Write-Error $Output $Body = "<p>An error occurred on $CAName while checking for pending certificate requests.</p><pre>" Foreach ($Line In $Output) { $Body += "$Line" + [Environment]::NewLine } $Body += "</pre>" Send-MailMessage -SmtpServer $SMTPServer -From $MailFrom -To $MailTo -Subject "$CAName Encountered An Error!" -Body $Body -BodyAsHtml Return } [Int]$NumberOfRequests = 0 If ([Int]::TryParse($Output[-2].Trim().Split(' ')[0], [ref] $NumberOfRequests)) { If ($NumberOfRequests -GT 0) { $Body = "<p>There are pending certificate requests on $CAName.</p><pre>" Foreach ($Line In $Output) { $Body += "$Line" + [Environment]::NewLine } $Body += "</pre>" Send-MailMessage -SmtpServer $SMTPServer -From $MailFrom -To $MailTo -Subject "$CAName Has Pending Requests" -Body $Body -BodyAsHtml } Else { Write-Host "No pending certificate requests found." } } Else { $Body = "<p>An error occurred on $CAName while checking for pending certificate requests.</p><pre>" Foreach ($Line In $Output) { $Body += "$Line" + [Environment]::NewLine } $Body += "</pre>" Send-MailMessage -SmtpServer $SMTPServer -From $MailFrom -To $MailTo -Subject "$CAName Encountered An Error!" -Body $Body -BodyAsHtml }