VirtualBox

Changeset 84380 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
May 19, 2020 7:42:11 PM (5 years ago)
Author:
vboxsync
Message:

IPRT/RTCrPkcs7: Added RTCRPKCS7VERIFY_SD_F_CHECK_TRUST_ANCHORS. Cleaned up @todo from r138008. bugref:9699

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/pkcs7-verify.cpp

    r84331 r84380  
    409409    PCRTCRCERTCTX           pSignerCertCtx = NULL;
    410410    PCRTCRX509CERTIFICATE   pSignerCert = NULL;
    411     RTCRSTORE               hSignerCertSrc = hTrustedCerts;
    412     if (hSignerCertSrc != NIL_RTCRSTORE)
    413         pSignerCertCtx = RTCrStoreCertByIssuerAndSerialNo(hSignerCertSrc, &pSignerInfo->IssuerAndSerialNumber.Name,
     411    if (hTrustedCerts != NIL_RTCRSTORE)
     412        pSignerCertCtx = RTCrStoreCertByIssuerAndSerialNo(hTrustedCerts, &pSignerInfo->IssuerAndSerialNumber.Name,
    414413                                                          &pSignerInfo->IssuerAndSerialNumber.SerialNumber);
    415     if (!pSignerCertCtx)
    416     {
    417         hSignerCertSrc = hAdditionalCerts;
    418         if (hSignerCertSrc != NIL_RTCRSTORE)
    419             pSignerCertCtx = RTCrStoreCertByIssuerAndSerialNo(hSignerCertSrc, &pSignerInfo->IssuerAndSerialNumber.Name,
    420                                                               &pSignerInfo->IssuerAndSerialNumber.SerialNumber);
    421     }
     414    if (!pSignerCertCtx && hAdditionalCerts != NIL_RTCRSTORE)
     415        pSignerCertCtx = RTCrStoreCertByIssuerAndSerialNo(hAdditionalCerts, &pSignerInfo->IssuerAndSerialNumber.Name,
     416                                                          &pSignerInfo->IssuerAndSerialNumber.SerialNumber);
    422417    if (pSignerCertCtx)
    423418        pSignerCert = pSignerCertCtx->pCert;
    424419    else
    425420    {
    426         hSignerCertSrc = NULL;
    427421        pSignerCert = RTCrPkcs7SetOfCerts_FindX509ByIssuerAndSerialNumber(&pSignedData->Certificates,
    428422                                                                          &pSignerInfo->IssuerAndSerialNumber.Name,
     
    436430
    437431    /*
    438      * If not a trusted certificate, we'll have to build certificate paths
    439      * and verify them.  If no valid paths are found, this step will fail.
    440      */
    441     int rc = VINF_SUCCESS;
    442     if (   /*(   hSignerCertSrc == NIL_RTCRSTORE
    443             || hSignerCertSrc != hTrustedCerts )
    444         &&*/ /** @todo 'hSignerCertSrc != hTrustedCerts' ain't making sense wrt pValidationTime */
    445         !(fFlags & RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS) )
     432     * Unless caller requesed all certificates to be trusted fully, we always
     433     * pass it on to the certificate path builder so it can do the requested
     434     * checks on trust anchors.   (We didn't used to do this as the path
     435     * builder could handle trusted targets.  A benefit here is that
     436     * pfnVerifyCert can assume a hCertPaths now, and get the validation time
     437     * from it if it wants it.)
     438     *
     439     * If no valid paths are found, this step will fail.
     440     */
     441    int rc;
     442    if (!(fFlags & RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS))
    446443    {
    447444        RTCRX509CERTPATHS hCertPaths;
     
    456453            if (pSignedData->Certificates.cItems > 0 && RT_SUCCESS(rc))
    457454                rc = RTCrX509CertPathsSetUntrustedSet(hCertPaths, &pSignedData->Certificates);
     455            if ((fFlags & RTCRPKCS7VERIFY_SD_F_CHECK_TRUST_ANCHORS) && RT_SUCCESS(rc))
     456                rc = RTCrX509CertPathsSetTrustAnchorChecks(hCertPaths, true /*fEnable*/);
    458457            if (RT_SUCCESS(rc))
    459458            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette