VirtualBox

Changeset 59669 in vbox


Ignore:
Timestamp:
Feb 15, 2016 12:36:48 AM (9 years ago)
Author:
vboxsync
Message:

ApplianceImplImport.cpp: started on certificate validation.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ApplianceImplPrivate.h

    r59621 r59669  
    6969      , hMemFileTheirManifest(NIL_RTVFSFILE)
    7070      , fSignerCertLoaded(false)
     71      , fCertificateValid(false)
    7172      , fSignatureValid(false)
    7273      , pbSignedDigest(NULL)
     
    127128        enmSignedDigestType    = RTDIGESTTYPE_INVALID;
    128129        fSignatureValid        = false;
     130        fCertificateValid      = false;
    129131        fDeterminedDigestTypes = false;
    130         fDigestTypes           = RTMANIFEST_ATTR_SHA1 | RTMANIFEST_ATTR_SHA256;
     132        fDigestTypes           = RTMANIFEST_ATTR_SHA1 | RTMANIFEST_ATTR_SHA256 | RTMANIFEST_ATTR_SHA512;
    131133    }
    132134
     
    165167    /** Set if the SignerCert member contains usable data. */
    166168    bool                fSignerCertLoaded;
    167     /** Set by read() if it found a certificate and the signature is fine. */
     169    /** Set by read() when the SignerCert checked out fine. */
     170    bool                fCertificateValid;
     171    /** Set by read() if pbSignedDigest verified correctly against SignerCert. */
    168172    bool                fSignatureValid;
    169173    /** The signed digest of the manifest. */
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r59626 r59669  
    16671667    else
    16681668        hrc = setErrorVrc(vrc, tr("Error reading the signer's certificate from '%s' for '%s' (%Rrc): %s"),
    1669                           pszSubFileNm, pTask->locInfo.strPath.c_str(), vrc, StaticErrInfo.szMsg);
     1669                          pszSubFileNm, pTask->locInfo.strPath.c_str(), vrc, StaticErrInfo.Core.pszMsg);
    16701670
    16711671    RTVfsIoStrmReadAllFree(pvSignature, cbSignature);
     
    17231723                    vrc = RTCrPkixSignatureVerify(hSignature, hDigest, m->pbSignedDigest, m->cbSignedDigest);
    17241724                    if (RT_SUCCESS(vrc))
     1725                    {
     1726                        m->fSignatureValid = true;
    17251727                        hrc = S_OK;
     1728                    }
    17261729                    else if (vrc == VERR_CR_PKIX_SIGNATURE_MISMATCH)
    17271730                        hrc = setErrorVrc(vrc, tr("The manifest signature does not match"));
     
    17411744        if (SUCCEEDED(hrc))
    17421745        {
     1746            if (RTCrX509Certificate_IsSelfSigned(&m->SignerCert))
     1747            {
     1748                /* Not entirely sure if we care whether a self issued certificate is
     1749                   marked as CA. But let's be a little bit picky about it for now. */
     1750                if (   m->SignerCert.TbsCertificate.T3.pBasicConstraints
     1751                    && m->SignerCert.TbsCertificate.T3.pBasicConstraints->CA.fValue)
     1752                {
     1753                    RTERRINFOSTATIC StaticErrInfo;
     1754                    vrc = RTCrX509Certificate_VerifySignatureSelfSigned(&m->SignerCert, RTErrInfoInitStatic(&StaticErrInfo));
     1755                    if (RT_SUCCESS(vrc))
     1756                        hrc = S_OK;
     1757                    else
     1758                        hrc = setErrorVrc(vrc, tr("Verification of the self signed certificate used to sign '%s' failed (%Rrc): %s"),
     1759                                          pTask->locInfo.strPath.c_str(), vrc, StaticErrInfo.Core.pszMsg);
     1760                }
     1761                else
     1762                    hrc = setError(E_FAIL,
     1763                                   tr("Self signed certificate used to sign '%s' is not marked as certificate authority (CA)"),
     1764                                   pTask->locInfo.strPath.c_str());
     1765            }
     1766            else
     1767            {
     1768
     1769            }
     1770
    17431771            /** @todo certificate validation. */
    17441772        }
    1745 
    17461773    }
    17471774
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