【问题标题】:OCSP revocation checking before completing TLS handshake完成 TLS 握手之前的 OCSP 吊销检查
【发布时间】:2019-04-11 11:53:21
【问题描述】:

我需要使用 Go 作为客户端在完成 TLS 握手之前对服务器证书进行 OCSP 吊销检查,即 [启动握手 -> 获取服务器证书 -> 检查吊销状态 -> 如果撤销中止],而不是[发起握手 -> 完成握手 -> 检查撤销状态]

使用 Go 的标准 TLS 库这似乎是不可能的,因为 tls.Dial 似乎没有进行任何 OCSP 检查。另一种可能的解决方法是在不执行握手的情况下获取服务器证书,然后检查吊销状态,如果状态正常,则使用 tls.Dial 重做握手,但我在 Go 中找不到这样做的方法。

关于如何解决这个特殊问题的任何建议?

【问题讨论】:

    标签: ssl go ocsp


    【解决方案1】:

    您可以在tls.Config 对象中设置VerifyPeerCertificate,如果撤销检查失败并且您希望中止握手,则让指向函数返回非零错误。

    来自docs

    // VerifyPeerCertificate, if not nil, is called after normal
    // certificate verification by either a TLS client or server. It
    // receives the raw ASN.1 certificates provided by the peer and also
    // any verified chains that normal processing found. If it returns a
    // non-nil error, the handshake is aborted and that error results.
    //
    // If normal verification fails then the handshake will abort before
    // considering this callback. If normal verification is disabled by
    // setting InsecureSkipVerify, or (for a server) when ClientAuth is
    // RequestClientCert or RequireAnyClientCert, then this callback will
    // be considered but the verifiedChains argument will always be nil.
    VerifyPeerCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error // Go 1.8
    

    【讨论】:

      猜你喜欢
      • 2021-01-02
      • 1970-01-01
      • 2011-06-24
      • 1970-01-01
      • 2021-03-31
      • 2018-01-15
      • 2012-03-25
      • 1970-01-01
      • 2020-08-04
      相关资源
      最近更新 更多