【问题标题】:Get Issuing CA from certutil dump or by serial number (Windows Server PKI)从 certutil 转储或序列号 (Windows Server PKI) 获取颁发 CA
【发布时间】:2021-11-15 23:53:57
【问题描述】:

有什么方法可以让证书颁发机构通过 certutil 命令或某个接口颁发证书,我可以将证书的序列号放入其中?

我们公司拥有由 5 个不同的 CA 颁发的数十万份证书。 每当我通过以下方式提取完整的转储(示例)时:

certutil -view -config "Issuing-CA01" -restrict "notbefore>22/09/2021" csv > C:\Users\XYZ\Desktop\dump.csv

我在此转储中找不到有关颁发 CA 的信息,其中包含 certutil 命令可以提供的所有可能的列。与 SAN 条目相同,除了证书本身之外,这些条目无法从任何转储中读取 - 但这属于不同的问题。

有什么方法可以通过命令行提取颁发的 CA?

【问题讨论】:

  • 在您的情况下颁发 CA 是“Issuing-CA01”。 certutil -view 返回的所有证书都是一样的。您究竟想了解您的 CA 的哪些方面?
  • 颁发 CA 在证书链上,没有必要向一个 CA 查询另一个 CA 证书。检查证书,而不是 CA。
  • @Sceptalist 因为这是可能的,而且很常见,例如KeyArchival,要导入(外部)证书(甚至是私钥),您可以在 ADCS 数据库中拥有由不同 CA 颁发的证书。

标签: powershell certificate x509certificate pki certutil


【解决方案1】:

发行者不是 ADCS 数据库架构中的列。因此,唯一的方法是获取证书本身,对其进行解析并打印出颁发者名称。

$tempFileName = "C:\Users\$env:UserName\AppData\Local\Temp\cert.cer";
& certutil -view -config "Issuing-CA01" -restrict "notbefore>22/09/2021" -out "RawCertificate" `
 | Out-File -FilePath $tempFileName;
[regex]::Matches( `
  (Get-Content $tempFileName), `
  "-----BEGIN CERTIFICATE-----[\s\r\n]{1}" + 
  "(?<cert>[a-z|A-Z|0-9|\+|\-|\\|\/|\s|\r|\n|=]*)" +
  "-----END CERTIFICATE-----", `
  [System.Text.RegularExpressions.RegexOptions]::Multiline) `
    | Foreach-Object {
      [System.IO.File]::WriteAllText(`
        $tempFileName, `
        $_.Groups["cert"].Value.Replace(" ", ""));
      $certificate = `
        New-Object System.Security.Cryptography.X509Certificates.X509Certificate2(`
          $tempFileName);

     Write-Host $certificate.Issuer;
}
Remove-Item $tempFileName;

【讨论】:

  • 非常感谢,您的方法帮助我找到了解决方案!
猜你喜欢
  • 1970-01-01
  • 2020-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-26
  • 1970-01-01
相关资源
最近更新 更多