VirtualBox

Changeset 59691 in vbox


Ignore:
Timestamp:
Feb 15, 2016 9:51:27 PM (9 years ago)
Author:
vboxsync
Message:

ApplianceImplImport.cpp: Use RTCrPkixPubKeyVerifySignedDigest so we get double verification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r59683 r59691  
    17041704         *
    17051705         * It's possible we should allow the user to ignore signature
    1706          * mismatches, but for now it's a show stopper.
     1706         * mismatches, but for now it is a solid show stopper.
    17071707         */
    17081708        HRESULT hrc;
     1709        RTERRINFOSTATIC StaticErrInfo;
    17091710
    17101711        /* Calc the digest of the manifest using the algorithm found above. */
     
    17161717            if (RT_SUCCESS(vrc))
    17171718            {
    1718                 /** @todo convert to something like RTCrPkixPubKeyVerifySignature!  */
    1719                 /* Verify the signature using the certificate. */
    1720                 RTCRPKIXSIGNATURE hSignature;
    1721                 vrc = RTCrPkixSignatureCreateByObjId(&hSignature,
    1722                                                      &m->SignerCert.TbsCertificate.SubjectPublicKeyInfo.Algorithm.Algorithm,
    1723                                                      false /*fSigning*/,
    1724                                                      &m->SignerCert.TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey,
    1725                                                      NULL);
     1719                /* Compare the signed digest with the one we just calculated.  (This
     1720                   API will do the verification twice, once using IPRT's own crypto
     1721                   and once using OpenSSL.  Both must OK it for success.) */
     1722                vrc = RTCrPkixPubKeyVerifySignedDigest(&m->SignerCert.TbsCertificate.SubjectPublicKeyInfo.Algorithm.Algorithm,
     1723                                                       &m->SignerCert.TbsCertificate.SubjectPublicKeyInfo.Algorithm.Parameters,
     1724                                                       &m->SignerCert.TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey,
     1725                                                       m->pbSignedDigest, m->cbSignedDigest, hDigest,
     1726                                                       RTErrInfoInitStatic(&StaticErrInfo));
    17261727                if (RT_SUCCESS(vrc))
    17271728                {
    1728                     vrc = RTCrPkixSignatureVerify(hSignature, hDigest, m->pbSignedDigest, m->cbSignedDigest);
    1729                     if (RT_SUCCESS(vrc))
    1730                     {
    1731                         m->fSignatureValid = true;
    1732                         hrc = S_OK;
    1733                     }
    1734                     else if (vrc == VERR_CR_PKIX_SIGNATURE_MISMATCH)
    1735                         hrc = setErrorVrc(vrc, tr("The manifest signature does not match"));
    1736                     else
    1737                         hrc = setErrorVrc(vrc, tr("Error validating the manifest signature (%Rrc)"), vrc);
    1738                     RTCrPkixSignatureRelease(hSignature);
     1729                    m->fSignatureValid = true;
     1730                    hrc = S_OK;
    17391731                }
     1732                else if (vrc == VERR_CR_PKIX_SIGNATURE_MISMATCH)
     1733                    hrc = setErrorVrc(vrc, tr("The manifest signature does not match"));
    17401734                else
    1741                     hrc = setErrorVrc(vrc, tr("RTCrPkixSignatureCreateByObjId failed: %Rrc"), vrc);
     1735                    hrc = setErrorVrc(vrc,
     1736                                      tr("Error validating the manifest signature (%Rrc, %s)"), vrc, StaticErrInfo.Core.pszMsg);
    17421737            }
    17431738            else
     
    17541749         * that till the import stage, so that we can allow the user to ignore it.
    17551750         *
    1756          * The certificate validity time is deliberately ignored as the OVF
    1757          * specification does not include a way of timestamping the signature
    1758          * and it would be seriously annoying for users if OVAs expired with
    1759          * their certificates.  This is of course a security concern, but the
    1760          * whole signing of OVFs is currently weirdly trusting (self signed
    1761          * certs), so this is the least of our current problems.
     1751         * The certificate validity time is deliberately left as warnings as the
     1752         * OVF specification does not provision for any timestamping of the
     1753         * signature. This is course a security concern, but the whole signing
     1754         * of OVFs is currently weirdly trusting (self signed * certs), so this
     1755         * is the least of our current problems.
     1756         *
     1757         * While we try build and verify certificate paths properly, the
     1758         * "neighbours" quietly ignores this and seems only to check the signature
     1759         * and not whether the certificate is trusted.  Also, we don't currently
     1760         * complain about self-signed certificates either (ditto "neighbours").
     1761         * The OVF creator is also a bit restricted wrt to helping us build the
     1762         * path as he cannot supply intermediate certificates.  Anyway, we issue
     1763         * warnings (goes to /dev/null, am I right?) for self-signed certificates
     1764         * and certificates we cannot build and verify a root path for.
     1765         *
     1766         * (The OVF sillibuggers should've used PKCS#7, CMS or something else
     1767         * that's already been standardized instead of combining manifests with
     1768         * certificate PEM files in some very restrictive manner!  I wonder if
     1769         * we could add a PKCS#7 section to the .cert file in addition to the CERT
     1770         * and manifest stuff dictated by the standard.  Would depend on how others
     1771         * deal with it.)
    17621772         */
    17631773        Assert(!m->fCertificateValid);
     
    17681778
    17691779        HRESULT hrc2 = S_OK;
    1770         RTERRINFOSTATIC StaticErrInfo;
    17711780        if (m->fCertificateIsSelfSigned)
    17721781        {
     
    17851794                RTTIMESPEC Now;
    17861795                if (RTCrX509Validity_IsValidAtTimeSpec(&m->SignerCert.TbsCertificate.Validity, RTTimeNow(&Now)))
     1796                {
    17871797                    m->fCertificateValidTime = true;
     1798                    i_addWarning(tr("A self signed certificate was used to sign '%s'"), pTask->locInfo.strPath.c_str());
     1799                }
    17881800                else
    17891801                    i_addWarning(tr("Self signed certificate used to sign '%s' is not currently valid"),
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