Microsoft OCSP 检查(OCSP 与轻量级 OCSP)和令人困惑的回复 "certutil -url"

Microsoft OCSP Check (OCSP vs Lightweight OCSP) & confusing Responses by "certutil -url"

#常规 OCSP (RFC 6960) 我写了一个 OCSP 响应程序,其中响应基于 RFC 6960 声明:

If nextUpdate is not set, the responder is indicating that newer revocation information is available all the time.

所以我没有设置 nextUpdate,只是像这里一样使用了 BouncyCastle BasicOCSPRespBuilder(它默认设置了 thisUpdate,在 Wireshark Capture 中也可以看到):

basicOCSPRespBuilder.addResponse(certID, responseList.get(certID));

但是这些响应被 IIS 中的证书验证器拒绝了。在尝试 certutil 时,响应状态始终为“已过期”。

这已使用“certutil -url”命令验证。

#轻量级 OCSP (RFC 5019) 一些谷歌搜索显示微软支持轻量级 OCSP RFC 5019 其中指出:

Clients MUST check for the existence of the nextUpdate field and MUST ensure the current time, expressed in GMT time as described in Section 2.2.4, falls between the thisUpdate and nextUpdate times. If the nextUpdate field is absent, the client MUST reject the response.

所以我修改了实现以包含 nextUpdate 日期(未来几分钟),如下所示:

basicOCSPRespBuilder.addResponse(certID, responseList.get(certID), getNextUpdateDate(), null);

这让我摆脱了“过期”状态问题,但现在的问题是,当它被部署到 Web 服务器并且我尝试执行“certutil -url”检查时,它 returns 证书中 WebProxy link 的“已验证”,但如果我直接提供服务器的 URL,它会显示“OK”。响应结构在两种情况下都保持不变,因为它是相同的响应者(使用 Wireshark Capture 验证,如果您愿意,我也可以附加它)。

#issuerKeyHash 字段 这里有趣的事实是,在通过 WebProxy 和 Direct URL 的情况下,发送到服务器的 OCSP 请求是不同的。区别在于 OCSP 请求在将请求发送到直接 link.

时不包括 issuerKeyHash

Wireshark 捕获发送到返回“已验证”的 Webproxy 的 OCSP 请求:-

发送到直接 link 的 OCSP 请求的 Wireshark 捕获返回状态“OK”:-

问题是为什么请求在一个实例中包含 issuerKeyHash 而在另一个实例中不包含。此外,为什么即使来自服务器的 OCSP 响应相似(由 Wireshark Caputres 确认),两个查询的状态也不相同。

对于“URL 检索工具”或“certutil -verify”在这方面的任何有见地的文档/link,我也将不胜感激。

我还可以根据要求包含 Wireshark 捕获。

我没有包含 Java 和 Bouncycastle 作为标签,因为 OCSP 响应被 Java、openssl 等接受,没有任何问题(根据 RFC 6960 有或没有 nextUpdate)。这个问题是为了了解 Microsoft certutil 和 OCSP 在此处检查的情况。

#更新#1 --- 开始更新 #1 ---

根据@Crypt32 的建议;我可以验证在 URL 字段中使用 URL 时,由于未知原因未构建完整的证书路径,因此缺少 IssuerKeyHash.

假设响应始终包含 IssuerKeyHash,这可能导致“正常”而不是“已验证”状态。为了确认这一点,我修改了响应以匹配请求,并且如果未在请求中交付但状态保持“正常”并且没有更改为“已验证”,则没有发送 IssuerKeyHash

目的是正确理解 Microsoft 应用程序如何处理 OCSP 响应以及如何正确实施 Responder,这样 Microsoft 应用程序就不会一败涂地。

研究正在进行中,如有任何意见和建议,我们将不胜感激!!

--- 结束更新#1 ---

回复。下次更新

Microsoft 使用 轻量级 OCSP,因此需要 thisUpdatenextUpdate 作为 RFC 5019.[=18 中引用的强制性要求=]

回复。 certutil

关于 certutil 的查询现已得到澄清,感谢 @Crypt32。

回复。 IssuerKeyHash

URL下载框中使用自定义URLcertutil时,没有生成完整的证书链因此导致没有 IssuerKeyHash.

的 OCSP 请求

标准 CryptoAPI 客户端从不发送带有空 IssuerKeyHash 的 OCSP 请求,这只是一种特殊的 certutil 行为,可能会被忽略,因为它也往往会因 Windows OCSP 服务器而失败(我也通过 Microsoft CA 进行了验证)

“certutil -url”的详细信息

仅部分回答。

“CertUtil”是一个通用的 Microsoft certificate/PKI 工具。它可以做很多事情。

现在这个 URL Retrieval Tool GUI 是当您使用“-url”参数启动它时发生的情况。

我觉得有点奇怪的是 -URL 参数没有公开记录。

  • 它没有在 Microsoft.com 文档中列出:https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
  • 它甚至没有在 ss64 上列出:https://ss64.com/nt/certutil.html
  • 它没有在 “CertUtil -v -? -- 显示所有动词的所有帮助文本” 中列出。只有 -URLCache-urlfetch 但没有 -url
    PS C:\> Get-Command certutil | select -expand fileversioninfo | fl filename, fileversion
    FileName    : C:\WINDOWS\system32\certutil.exe
    FileVersion : 10.0.19041.1 (WinBuild.160101.0800)
    
    PS C:\> certutil -v -? | select-string ' -url'
      -URLCache         -- Display or delete URL cache entries
      CertUtil [Options] -URLCache [URL | CRL | * [delete]]
      -urlfetch         -- Retrieve and verify AIA Certs and CDP CRLs
    

但它确实有一些帮助文本,如果您具体要求的话:

C:\> certutil.exe -URL -?
Usage:
  CertUtil [Options] -URL InFile | URL
  Verify Certificate or CRL URLs

Options:
  -f                -- Force overwrite
  -Unicode          -- Write redirected output in Unicode
  -gmt              -- Display times as GMT
  -seconds          -- Display times with seconds and milliseconds
  -split            -- Split embedded ASN.1 elements, and save to files
  -v                -- Verbose operation
  -privatekey       -- Display password and private key data
  -pin PIN                  -- Smart Card PIN
  -sid WELL_KNOWN_SID_TYPE  -- Numeric SID
            22 -- Local System
            23 -- Local Service
            24 -- Network Service

CertUtil -?              -- Display a verb list (command list)
CertUtil -URL -?         -- Display help text for the "URL" verb
CertUtil -v -?           -- Display all help text for all verbs

要显示“URL 检索工具”GUI,您可以像这样启动 certutil。

C:\> certutil -url http://example.com