【问题标题】:Do the openssl X509_verify_cert() verifies the signature in the certificate?openssl X509_verify_cert() 是否验证证书中的签名?
【发布时间】:2012-05-08 09:22:00
【问题描述】:

openssl X509_verify_cert() API 会验证证书中的 RSA 签名吗?

据我了解,该 API 仅检查证书有效性(如日期检查等)。

有人请澄清一下吗?

【问题讨论】:

    标签: c linux openssl


    【解决方案1】:

    API X509_verify_cert() 根据您在 X509_store 结构中设置的验证标志进行验证。 使用此 API,您可以验证证书
    1.到期
    2.Issuer(信任路径)
    2.1 中间证书到期,
    2.2 中间证书信任链,
    2.3 中间证书吊销,
    3.撤销针对 CRL 的证书
    3.1 CRL 到期
    3.2 CRL 信任路径
    (注意:验证 CRL,您需要在 store_ctx 变量中至少有一个证书)
    4.信任链深度
    5.证书签名

    x509_vfy.h 文件中提到了用于不同验证的标志

            /* Send issuer+subject checks to verify_cb */
           #define  X509_V_FLAG_CB_ISSUER_CHECK     0x1
          /* Use check time instead of current time */
           #define  X509_V_FLAG_USE_CHECK_TIME      0x2
          /* Lookup CRLs */
          #define   X509_V_FLAG_CRL_CHECK           0x4
            /* Lookup CRLs for whole chain */
          #define   X509_V_FLAG_CRL_CHECK_ALL       0x8
            /* Ignore unhandled critical extensions */
          #define   X509_V_FLAG_IGNORE_CRITICAL     0x10
         /* Disable workarounds for broken certificates */
         #define    X509_V_FLAG_X509_STRICT         0x20
         /* Enable proxy certificate validation */
          #define   X509_V_FLAG_ALLOW_PROXY_CERTS       0x40
          /* Enable policy checking */
            #define X509_V_FLAG_POLICY_CHECK        0x80
         /* Policy variable require-explicit-policy */
       #define X509_V_FLAG_EXPLICIT_POLICY      0x100
        /* Policy variable inhibit-any-policy */
        #define X509_V_FLAG_INHIBIT_ANY         0x200
         /* Policy variable inhibit-policy-mapping */
          #define X509_V_FLAG_INHIBIT_MAP           0x400
        /* Notify callback that policy is OK */
         #define X509_V_FLAG_NOTIFY_POLICY      0x800
         /* Extended CRL features such as indirect CRLs, alternate CRL signing keys */
         #define X509_V_FLAG_EXTENDED_CRL_SUPPORT   0x1000
        /* Delt1a CRL support */
        #define X509_V_FLAG_USE_DELTAS          0x2000
         /* Check selfsigned CA signature */
       #define X509_V_FLAG_CHECK_SS_SIGNATURE       0x4000
    

    【讨论】:

      【解决方案2】:

      X509_verify_cert() 本质上是检查证书的有效性。这包括验证已签署属于 CA 的证书的签名是否有效并且是最新的 - 它将像这样处理整个链。

      但是,它不会验证给定的 RSA 签名是否有效 - 尽管它会验证 RSA 签名作为其工作的一部分,但这不是您应该使用的。

      从广义上讲,它类似于当您在浏览 SSL 站点时遇到证书错误时运行的功能。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 2020-03-15
        • 2019-01-09
        • 1970-01-01
        • 1970-01-01
        • 2012-08-24
        • 1970-01-01
        相关资源
        最近更新 更多