Changeset 59691 in vbox
- Timestamp:
- Feb 15, 2016 9:51:27 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r59683 r59691 1704 1704 * 1705 1705 * It's possible we should allow the user to ignore signature 1706 * mismatches, but for now it 's ashow stopper.1706 * mismatches, but for now it is a solid show stopper. 1707 1707 */ 1708 1708 HRESULT hrc; 1709 RTERRINFOSTATIC StaticErrInfo; 1709 1710 1710 1711 /* Calc the digest of the manifest using the algorithm found above. */ … … 1716 1717 if (RT_SUCCESS(vrc)) 1717 1718 { 1718 /* * @todo convert to something like RTCrPkixPubKeyVerifySignature! */1719 /* Verify the signature using the certificate. */1720 RTCRPKIXSIGNATURE hSignature;1721 vrc = RTCrPkix SignatureCreateByObjId(&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)); 1726 1727 if (RT_SUCCESS(vrc)) 1727 1728 { 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; 1739 1731 } 1732 else if (vrc == VERR_CR_PKIX_SIGNATURE_MISMATCH) 1733 hrc = setErrorVrc(vrc, tr("The manifest signature does not match")); 1740 1734 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); 1742 1737 } 1743 1738 else … … 1754 1749 * that till the import stage, so that we can allow the user to ignore it. 1755 1750 * 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.) 1762 1772 */ 1763 1773 Assert(!m->fCertificateValid); … … 1768 1778 1769 1779 HRESULT hrc2 = S_OK; 1770 RTERRINFOSTATIC StaticErrInfo;1771 1780 if (m->fCertificateIsSelfSigned) 1772 1781 { … … 1785 1794 RTTIMESPEC Now; 1786 1795 if (RTCrX509Validity_IsValidAtTimeSpec(&m->SignerCert.TbsCertificate.Validity, RTTimeNow(&Now))) 1796 { 1787 1797 m->fCertificateValidTime = true; 1798 i_addWarning(tr("A self signed certificate was used to sign '%s'"), pTask->locInfo.strPath.c_str()); 1799 } 1788 1800 else 1789 1801 i_addWarning(tr("Self signed certificate used to sign '%s' is not currently valid"),
Note:
See TracChangeset
for help on using the changeset viewer.