VirtualBox

Changeset 95690 in vbox


Ignore:
Timestamp:
Jul 18, 2022 12:59:34 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152340
Message:

RTSignTool: Don't add the dummy timestamp certificate we feed to OpenSSL when using a certificate with a private key in a windows crypto store. Cleaned up that real vs dummy cert thing a little better. bugref:8691

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/tools/RTSignTool.cpp

    r95688 r95690  
    780780    }
    781781
     782    /** Returns the real certificate. */
     783    PCRTCRX509CERTIFICATE getRealCertificate() const
     784    {
     785#ifdef RT_OS_WINDOWS
     786        if (pCertificateReal)
     787            return pCertificateReal;
     788#endif
     789        return pCertificate;
     790    }
     791
    782792#ifdef RT_OS_WINDOWS
    783793    RTEXITCODE loadFakePrivateKeyAndCert()
     
    20072017     */
    20082018    PRTCRPKCS7SIGNEDDATA pSignedData = pContentInfo->u.pSignedData;
    2009     unsigned iCert = pSignedData->Certificates.cItems;
     2019    unsigned             iCert       = pSignedData->Certificates.cItems;
     2020    unsigned             cErased     = 0;
    20102021    while (iCert-- > 0)
    20112022    {
     
    20152026                                                              &pCertKeyPair->pCertificate->TbsCertificate.Issuer,
    20162027                                                              &pCertKeyPair->pCertificate->TbsCertificate.SerialNumber))
     2028        {
    20172029            RTCrPkcs7SetOfCerts_Erase(&pSignedData->Certificates, iCert);
    2018     }
     2030            cErased++;
     2031        }
     2032    }
     2033    if (cErased == 0)
     2034        return RTMsgErrorExitFailure("(%s) Failed to find temporary signing certificate in PKCS#7 from OpenSSL: %u certs",
     2035                                     pszWhat, pSignedData->Certificates.cItems);
    20192036
    20202037    /* Then insert the real signing certificate. */
    2021     RTEXITCODE rcExit = SignToolPkcs7_AppendCertificate(pSignedData, pCertKeyPair->pCertificateReal);
     2038    PCRTCRX509CERTIFICATE const pRealCertificate = pCertKeyPair->getRealCertificate();
     2039    RTEXITCODE rcExit = SignToolPkcs7_AppendCertificate(pSignedData, pRealCertificate);
    20222040    if (rcExit != RTEXITCODE_SUCCESS)
    20232041        return rcExit;
     
    20292047    RTCrX509Name_Delete(&pSignerInfo->IssuerAndSerialNumber.Name);
    20302048    int rc = RTCrX509Name_Clone(&pSignerInfo->IssuerAndSerialNumber.Name,
    2031                                 &pCertKeyPair->pCertificateReal->TbsCertificate.Issuer, &g_RTAsn1DefaultAllocator);
     2049                                &pRealCertificate->TbsCertificate.Issuer, &g_RTAsn1DefaultAllocator);
    20322050    if (RT_FAILURE(rc))
    20332051        return RTMsgErrorExitFailure("(%s) RTCrX509Name_Clone failed: %Rrc", pszWhat, rc);
     
    20352053    RTAsn1Integer_Delete(&pSignerInfo->IssuerAndSerialNumber.SerialNumber);
    20362054    rc = RTAsn1Integer_Clone(&pSignerInfo->IssuerAndSerialNumber.SerialNumber,
    2037                              &pCertKeyPair->pCertificateReal->TbsCertificate.SerialNumber, &g_RTAsn1DefaultAllocator);
     2055                             &pRealCertificate->TbsCertificate.SerialNumber, &g_RTAsn1DefaultAllocator);
    20382056    if (RT_FAILURE(rc))
    20392057        return RTMsgErrorExitFailure("(%s) RTAsn1Integer_Clone failed: %Rrc", pszWhat, rc);
     
    22732291
    22742292    RTEXITCODE rcExit = SignToolPkcs7_AddAuthAttribsForTimestamp(&AuthAttribs, fTimestampTypeOld, SigningTime,
    2275                                                                  pTimestampPair->pCertificate);
     2293                                                                 pTimestampPair->getRealCertificate());
    22762294    if (rcExit == RTEXITCODE_SUCCESS)
    22772295    {
     
    23222340            if (rcExit == RTEXITCODE_SUCCESS)
    23232341            {
    2324                 rcExit = SignToolPkcs7_AppendCertificate(pSignedData, pTimestampPair->pCertificate);
     2342                rcExit = SignToolPkcs7_AppendCertificate(pSignedData, pTimestampPair->getRealCertificate());
    23252343
    23262344                PCRTCRCERTCTX pInterCaCtx = NULL;
Note: See TracChangeset for help on using the changeset viewer.

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