VirtualBox

Changeset 106265 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Oct 9, 2024 8:52:03 PM (7 weeks ago)
Author:
vboxsync
Message:

Additions/NT/Installer: Just use IPRT verify the stupid file signatures, that'll work on all windows versions and with all types of certificates we use. bugref:10771

Location:
trunk/src/VBox/Additions/WINNT/Installer/Loader
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/Loader/Makefile.kmk

    r106255 r106265  
    7777  VBoxWindowsAdditions_ORDERDEPS     = $(VBOX_SIGN_IMAGE_ORDERDEPS)
    7878 endif
    79  VBoxWindowsAdditions_DEFS         += VBOX_SIGNING_MODE
    80  VBoxWindowsAdditions_INCS         += $(VBoxWindowsAdditions_0_OUTDIR)
    81  VBoxWindowsAdditions_INTERMEDIATES = $(VBoxWindowsAdditions_0_OUTDIR)/BuildCert.h
     79 VBoxWindowsAdditions_DEFS          += VBOX_SIGNING_MODE
     80 VBoxWindowsAdditions_INCS          += $(VBoxWindowsAdditions_0_OUTDIR)
     81 VBoxWindowsAdditions_INTERMEDIATES += \
     82        $(VBoxWindowsAdditions_0_OUTDIR)/BuildCerts.h  \
     83        $(VBoxWindowsAdditions_0_OUTDIR)/TimestampRootCerts.h
     84 VBoxWindowsAdditions_CLEAN         += \
     85        $(VBoxWindowsAdditions_0_OUTDIR)/BuildCerts.h  \
     86        $(VBoxWindowsAdditions_0_OUTDIR)/TimestampRootCerts.h
    8287
    8388 # Dummy signed program that we can extract the signature from.
     
    8893 bldAddSignedDummy_POST_CMDS = $(call VBOX_SIGN_IMAGE_FN,$(out),,2)
    8994
    90  # The certificate include file.
    91  $$(VBoxWindowsAdditions_0_OUTDIR)/BuildCert.h: \
    92                 $(VBOX_BIN2C) \
    93                 $(VBOX_RTSIGNTOOL) \
    94                 $$(bldAddSignedDummy_1_TARGET) \
    95                 | $$(dir $$@)
    96         $(QUIET)$(RM) -f -- "$@" "[email protected]"
    97         $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --exe "$(bldAddSignedDummy_1_TARGET)" --output "[email protected]" --der
    98         $(VBOX_BIN2C) -ascii --append BuildCert "[email protected]" "$@"
    99         $(QUIET)$(RM) -f -- [email protected]
     95 # The certificate include files.
     96 $$(VBoxWindowsAdditions_0_OUTDIR)/BuildCerts.h: $(VBOX_RTSIGNTOOL) $$(bldAddSignedDummy_1_TARGET) | $$(dir $$@)
     97        $(QUIET)$(RM) -f -- "$@"
     98        $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --as-c-array "BuildCerts" "$(bldAddSignedDummy_1_TARGET)" --output "$@"
     99
     100 $$(VBoxWindowsAdditions_0_OUTDIR)/TimestampRootCerts.h: $(VBOX_RTSIGNTOOL) $$(bldAddSignedDummy_1_TARGET) | $$(dir $$@)
     101        $(QUIET)$(RM) -f -- "$@"
     102        $(VBOX_RTSIGNTOOL) extract-timestamp-root -R --as-c-array "TimestampRootCerts" "$(bldAddSignedDummy_1_TARGET)" --output "$@"
    100103
    101104 OTHER_CLEAN += $(VBOX_SUP_WIN_CERTS_FILE)
  • trunk/src/VBox/Additions/WINNT/Installer/Loader/VBoxWindowsAdditions.cpp

    r106255 r106265  
    4747
    4848#ifdef VBOX_SIGNING_MODE
    49 # include "BuildCert.h"
     49# include "BuildCerts.h"
     50# include "TimestampRootCerts.h"
    5051#endif
    5152
    5253
    5354#ifdef VBOX_SIGNING_MODE
     55# if 1 /* Whether to use IPRT or Windows to verify the executable signatures. */
     56/* This section is borrowed from RTSignTool.cpp */
     57
     58#  include <iprt/err.h>
     59#  include <iprt/initterm.h>
     60#  include <iprt/ldr.h>
     61#  include <iprt/message.h>
     62#  include <iprt/stream.h>
     63#  include <iprt/crypto/pkcs7.h>
     64#  include <iprt/crypto/store.h>
     65
     66class CryptoStore
     67{
     68public:
     69    RTCRSTORE m_hStore;
     70
     71    CryptoStore()
     72        : m_hStore(NIL_RTCRSTORE)
     73    {
     74    }
     75
     76    ~CryptoStore()
     77    {
     78        if (m_hStore != NIL_RTCRSTORE)
     79        {
     80            uint32_t cRefs = RTCrStoreRelease(m_hStore);
     81            Assert(cRefs == 0); RT_NOREF(cRefs);
     82            m_hStore = NIL_RTCRSTORE;
     83        }
     84    }
     85
     86    /**
     87     * Adds one or more certificates from the given file.
     88     *
     89     * @returns boolean success indicator.
     90     */
     91    bool addFromFile(const char *pszFilename, PRTERRINFOSTATIC pStaticErrInfo)
     92    {
     93        int rc = RTCrStoreCertAddFromFile(this->m_hStore, RTCRCERTCTX_F_ADD_IF_NOT_FOUND | RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR,
     94                                          pszFilename, RTErrInfoInitStatic(pStaticErrInfo));
     95        if (RT_SUCCESS(rc))
     96        {
     97            if (RTErrInfoIsSet(&pStaticErrInfo->Core))
     98                RTMsgWarning("Warnings loading certificate '%s': %s", pszFilename, pStaticErrInfo->Core.pszMsg);
     99            return true;
     100        }
     101        RTMsgError("Error loading certificate '%s': %Rrc%#RTeim", pszFilename, rc, &pStaticErrInfo->Core);
     102        return false;
     103    }
     104
     105    /**
     106     * Adds trusted self-signed certificates from the system.
     107     *
     108     * @returns boolean success indicator.
     109     * @note The selection is self-signed rather than CAs here so that test signing
     110     *       certificates will be included.
     111     */
     112    bool addSelfSignedRootsFromSystem(PRTERRINFOSTATIC pStaticErrInfo)
     113    {
     114        CryptoStore Tmp;
     115        int rc = RTCrStoreCreateSnapshotOfUserAndSystemTrustedCAsAndCerts(&Tmp.m_hStore, RTErrInfoInitStatic(pStaticErrInfo));
     116        if (RT_SUCCESS(rc))
     117        {
     118            RTCRSTORECERTSEARCH Search;
     119            rc = RTCrStoreCertFindAll(Tmp.m_hStore, &Search);
     120            if (RT_SUCCESS(rc))
     121            {
     122                PCRTCRCERTCTX pCertCtx;
     123                while ((pCertCtx = RTCrStoreCertSearchNext(Tmp.m_hStore, &Search)) != NULL)
     124                {
     125                    /* Add it if it's a full fledged self-signed certificate, otherwise just skip: */
     126                    if (   pCertCtx->pCert
     127                        && RTCrX509Certificate_IsSelfSigned(pCertCtx->pCert))
     128                    {
     129                        int rc2 = RTCrStoreCertAddEncoded(this->m_hStore,
     130                                                          pCertCtx->fFlags | RTCRCERTCTX_F_ADD_IF_NOT_FOUND,
     131                                                          pCertCtx->pabEncoded, pCertCtx->cbEncoded, NULL);
     132                        if (RT_FAILURE(rc2))
     133                            RTMsgWarning("RTCrStoreCertAddEncoded failed for a certificate: %Rrc", rc2);
     134                    }
     135                    RTCrCertCtxRelease(pCertCtx);
     136                }
     137
     138                int rc2 = RTCrStoreCertSearchDestroy(Tmp.m_hStore, &Search);
     139                AssertRC(rc2);
     140                return true;
     141            }
     142            RTMsgError("RTCrStoreCertFindAll failed: %Rrc", rc);
     143        }
     144        else
     145            RTMsgError("RTCrStoreCreateSnapshotOfUserAndSystemTrustedCAsAndCerts failed: %Rrc%#RTeim", rc, &pStaticErrInfo->Core);
     146        return false;
     147    }
     148
     149    /**
     150     * Adds trusted self-signed certificates from the system.
     151     *
     152     * @returns boolean success indicator.
     153     */
     154    bool addIntermediateCertsFromSystem(PRTERRINFOSTATIC pStaticErrInfo)
     155    {
     156        bool fRc = true;
     157        RTCRSTOREID const s_aenmStoreIds[] = { RTCRSTOREID_SYSTEM_INTERMEDIATE_CAS, RTCRSTOREID_USER_INTERMEDIATE_CAS };
     158        for (size_t i = 0; i < RT_ELEMENTS(s_aenmStoreIds); i++)
     159        {
     160            CryptoStore Tmp;
     161            int rc = RTCrStoreCreateSnapshotById(&Tmp.m_hStore, s_aenmStoreIds[i], RTErrInfoInitStatic(pStaticErrInfo));
     162            if (RT_SUCCESS(rc))
     163            {
     164                RTCRSTORECERTSEARCH Search;
     165                rc = RTCrStoreCertFindAll(Tmp.m_hStore, &Search);
     166                if (RT_SUCCESS(rc))
     167                {
     168                    PCRTCRCERTCTX pCertCtx;
     169                    while ((pCertCtx = RTCrStoreCertSearchNext(Tmp.m_hStore, &Search)) != NULL)
     170                    {
     171                        /* Skip selfsigned certs as they're useless as intermediate certs (IIRC). */
     172                        if (   pCertCtx->pCert
     173                            && !RTCrX509Certificate_IsSelfSigned(pCertCtx->pCert))
     174                        {
     175                            int rc2 = RTCrStoreCertAddEncoded(this->m_hStore,
     176                                                              pCertCtx->fFlags | RTCRCERTCTX_F_ADD_IF_NOT_FOUND,
     177                                                              pCertCtx->pabEncoded, pCertCtx->cbEncoded, NULL);
     178                            if (RT_FAILURE(rc2))
     179                                RTMsgWarning("RTCrStoreCertAddEncoded failed for a certificate: %Rrc", rc2);
     180                        }
     181                        RTCrCertCtxRelease(pCertCtx);
     182                    }
     183
     184                    int rc2 = RTCrStoreCertSearchDestroy(Tmp.m_hStore, &Search);
     185                    AssertRC(rc2);
     186                }
     187                else
     188                {
     189                    RTMsgError("RTCrStoreCertFindAll/%d failed: %Rrc", s_aenmStoreIds[i], rc);
     190                    fRc = false;
     191                }
     192            }
     193            else
     194            {
     195                RTMsgError("RTCrStoreCreateSnapshotById/%d failed: %Rrc%#RTeim", s_aenmStoreIds[i], rc, &pStaticErrInfo->Core);
     196                fRc = false;
     197            }
     198        }
     199        return fRc;
     200    }
     201
     202};
     203
     204typedef struct VERIFYEXESTATE
     205{
     206    CryptoStore RootStore;
     207    CryptoStore KernelRootStore;
     208    CryptoStore AdditionalStore;
     209    bool        fKernel;
     210    int         cVerbose;
     211    enum { kSignType_Windows, kSignType_OSX } enmSignType;
     212    RTLDRARCH   enmLdrArch;
     213    uint32_t    cBad;
     214    uint32_t    cOkay;
     215    uint32_t    cTrustedCerts;
     216    const char *pszFilename;
     217    RTTIMESPEC  ValidationTime;
     218
     219    VERIFYEXESTATE()
     220        : fKernel(false)
     221        , cVerbose(0)
     222        , enmSignType(kSignType_Windows)
     223        , enmLdrArch(RTLDRARCH_WHATEVER)
     224        , cBad(0)
     225        , cOkay(0)
     226        , cTrustedCerts(0)
     227        , pszFilename(NULL)
     228    {
     229        RTTimeSpecSetSeconds(&ValidationTime, 0);
     230    }
     231} VERIFYEXESTATE;
     232
     233/**
     234 * @callback_method_impl{FNRTCRPKCS7VERIFYCERTCALLBACK,
     235 * Standard code signing.  Use this for Microsoft SPC.}
     236 */
     237static DECLCALLBACK(int) VerifyExecCertVerifyCallback(PCRTCRX509CERTIFICATE pCert, RTCRX509CERTPATHS hCertPaths, uint32_t fFlags,
     238                                                      void *pvUser, PRTERRINFO pErrInfo)
     239{
     240    VERIFYEXESTATE * const pState = (VERIFYEXESTATE *)pvUser;
     241
     242    /* We don't set RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS, so it won't be NIL! */
     243    Assert(hCertPaths != NIL_RTCRX509CERTPATHS);
     244
     245#  if 0 /* for debugging */
     246    uint32_t const cPaths = RTCrX509CertPathsGetPathCount(hCertPaths);
     247    RTMsgInfo("%s Path%s (pCert=%p hCertPaths=%p fFlags=%#x cPath=%d):",
     248              fFlags & RTCRPKCS7VCC_F_TIMESTAMP ? "Timestamp" : "Signature", cPaths == 1 ? "" : "s",
     249              pCert, hCertPaths, fFlags, cPaths);
     250    for (uint32_t iPath = 0; iPath < cPaths; iPath++)
     251    {
     252        RTCrX509CertPathsDumpOne(hCertPaths, iPath, pState->cVerbose, RTStrmDumpPrintfV, g_pStdOut);
     253        *pErrInfo->pszMsg = '\0';
     254    }
     255#  endif
     256
     257    /*
     258     * Standard code signing capabilites required.
     259     *
     260     * Note! You may have to fix your test signing cert / releax this one to pass this.
     261     */
     262    int rc = RTCrPkcs7VerifyCertCallbackCodeSigning(pCert, hCertPaths, fFlags, NULL, pErrInfo);
     263    if (RT_SUCCESS(rc))
     264    {
     265        /*
     266         * Check if the signing certificate is a trusted one, i.e. one of the
     267         * build certificates.
     268         */
     269        if (!(fFlags & RTCRPKCS7VCC_F_TIMESTAMP))
     270            if (RTCrX509CertPathsGetPathCount(hCertPaths) == 1)
     271                if (RTCrX509CertPathsGetPathLength(hCertPaths, 0) == 1)
     272                {
     273                    RTMsgInfo("Signed by trusted certificate.\n");
     274                    pState->cTrustedCerts++;
     275                }
     276    }
     277    else
     278        RTMsgError("RTCrPkcs7VerifyCertCallbackCodeSigning(,,%#x,,) failed: %Rrc%#RTeim", fFlags, pErrInfo);
     279    return rc;
     280}
     281
     282/** @callback_method_impl{FNRTLDRVALIDATESIGNEDDATA}  */
     283static DECLCALLBACK(int) VerifyExeCallback(RTLDRMOD hLdrMod, PCRTLDRSIGNATUREINFO pInfo, PRTERRINFO pErrInfo, void *pvUser)
     284{
     285    VERIFYEXESTATE * const pState = (VERIFYEXESTATE *)pvUser;
     286    RT_NOREF_PV(hLdrMod);
     287
     288    switch (pInfo->enmType)
     289    {
     290        case RTLDRSIGNATURETYPE_PKCS7_SIGNED_DATA:
     291        {
     292            PCRTCRPKCS7CONTENTINFO pContentInfo = (PCRTCRPKCS7CONTENTINFO)pInfo->pvSignature;
     293
     294            if (pState->cVerbose > 0)
     295                RTMsgInfo("Verifying '%s' signature #%u ...\n", pState->pszFilename, pInfo->iSignature + 1);
     296
     297#  if 0
     298            /*
     299             * Dump the signed data if so requested and it's the first one, assuming that
     300             * additional signatures in contained wihtin the same ContentInfo structure.
     301             */
     302            if (pState->cVerbose > 1 && pInfo->iSignature == 0)
     303                RTAsn1Dump(&pContentInfo->SeqCore.Asn1Core, 0, 0, RTStrmDumpPrintfV, g_pStdOut);
     304#  endif
     305
     306            /*
     307             * We'll try different alternative timestamps here.
     308             */
     309            struct { RTTIMESPEC TimeSpec; const char *pszDesc; } aTimes[3];
     310            unsigned cTimes = 0;
     311
     312            /* The specified timestamp. */
     313            if (RTTimeSpecGetSeconds(&pState->ValidationTime) != 0)
     314            {
     315                aTimes[cTimes].TimeSpec = pState->ValidationTime;
     316                aTimes[cTimes].pszDesc  = "validation time";
     317                cTimes++;
     318            }
     319
     320            /* Linking timestamp: */
     321            uint64_t uLinkingTime = 0;
     322            int rc = RTLdrQueryProp(hLdrMod, RTLDRPROP_TIMESTAMP_SECONDS, &uLinkingTime, sizeof(uLinkingTime));
     323            if (RT_SUCCESS(rc))
     324            {
     325                RTTimeSpecSetSeconds(&aTimes[cTimes].TimeSpec, uLinkingTime);
     326                aTimes[cTimes].pszDesc = "at link time";
     327                cTimes++;
     328            }
     329            else if (rc != VERR_NOT_FOUND)
     330                RTMsgError("RTLdrQueryProp/RTLDRPROP_TIMESTAMP_SECONDS failed on '%s': %Rrc\n", pState->pszFilename, rc);
     331
     332            /* Now: */
     333            RTTimeNow(&aTimes[cTimes].TimeSpec);
     334            aTimes[cTimes].pszDesc = "now";
     335            cTimes++;
     336
     337            /*
     338             * Do the actual verification.
     339             */
     340            Assert(!pInfo->pvExternalData);
     341            for (unsigned iTime = 0; iTime < cTimes; iTime++)
     342            {
     343                RTTIMESPEC TimeSpec = aTimes[iTime].TimeSpec;
     344                rc = RTCrPkcs7VerifySignedData(pContentInfo,
     345                                               RTCRPKCS7VERIFY_SD_F_COUNTER_SIGNATURE_SIGNING_TIME_ONLY
     346                                               | RTCRPKCS7VERIFY_SD_F_ALWAYS_USE_SIGNING_TIME_IF_PRESENT
     347                                               | RTCRPKCS7VERIFY_SD_F_ALWAYS_USE_MS_TIMESTAMP_IF_PRESENT
     348                                               | RTCRPKCS7VERIFY_SD_F_CHECK_TRUST_ANCHORS
     349                                               | RTCRPKCS7VERIFY_SD_F_UPDATE_VALIDATION_TIME,
     350                                               pState->AdditionalStore.m_hStore, pState->RootStore.m_hStore,
     351                                               &TimeSpec, VerifyExecCertVerifyCallback, pState, pErrInfo);
     352                if (RT_SUCCESS(rc))
     353                {
     354                    Assert(rc == VINF_SUCCESS || rc == VINF_CR_DIGEST_DEPRECATED);
     355                    const char * const pszNote = rc == VINF_CR_DIGEST_DEPRECATED ? " (deprecated digest)" : "";
     356                    const char * const pszTime =    iTime == 0
     357                                                 && RTTimeSpecCompare(&TimeSpec, &aTimes[iTime].TimeSpec) != 0
     358                                               ? "at signing time" : aTimes[iTime].pszDesc;
     359                    if (pInfo->cSignatures == 1)
     360                        RTMsgInfo("'%s' is valid %s%s.\n", pState->pszFilename, pszTime, pszNote);
     361                    else
     362                        RTMsgInfo("'%s' signature #%u is valid %s%s.\n",
     363                                  pState->pszFilename, pInfo->iSignature + 1, pszTime, pszNote);
     364                    pState->cOkay++;
     365                    return VINF_SUCCESS;
     366                }
     367                if (rc != VERR_CR_X509_CPV_NOT_VALID_AT_TIME)
     368                {
     369                    if (pInfo->cSignatures == 1)
     370                        RTMsgError("%s: Failed to verify signature: %Rrc%#RTeim\n", pState->pszFilename, rc, pErrInfo);
     371                    else
     372                        RTMsgError("%s: Failed to verify signature #%u: %Rrc%#RTeim\n",
     373                                   pState->pszFilename, pInfo->iSignature + 1, rc, pErrInfo);
     374                    pState->cBad++;
     375                    return VINF_SUCCESS;
     376                }
     377            }
     378
     379            if (pInfo->cSignatures == 1)
     380                RTMsgError("%s: Signature is not valid at present or link time.\n", pState->pszFilename);
     381            else
     382                RTMsgError("%s: Signature #%u is not valid at present or link time.\n",
     383                           pState->pszFilename, pInfo->iSignature + 1);
     384            pState->cBad++;
     385            return VINF_SUCCESS;
     386        }
     387
     388        default:
     389            return RTErrInfoSetF(pErrInfo, VERR_NOT_SUPPORTED, "Unsupported signature type: %d", pInfo->enmType);
     390    }
     391}
     392
     393/**
     394 * Uses IPRT functionality to check that the executable is signed with a
     395 * certiicate known to us.
     396 *
     397 * @returns 0 on success, non-zero exit code on failure.
     398 */
     399static int CheckFileSignatureIprt(wchar_t const *pwszExePath)
     400{
     401    RTR3InitExeNoArguments(RTR3INIT_FLAGS_STANDALONE_APP);
     402    RTMsgInfo("Signing checking of '%ls'...\n", pwszExePath);
     403
     404    /* Initialize the state. */
     405    VERIFYEXESTATE State;
     406    int rc = RTCrStoreCreateInMem(&State.RootStore.m_hStore, 0);
     407    if (RT_SUCCESS(rc))
     408        rc = RTCrStoreCreateInMem(&State.KernelRootStore.m_hStore, 0);
     409    if (RT_SUCCESS(rc))
     410        rc = RTCrStoreCreateInMem(&State.AdditionalStore.m_hStore, 0);
     411    if (RT_FAILURE(rc))
     412        return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error creating in-memory certificate store: %Rrc", rc);
     413
     414    /* Add the build certificates to the root store. */
     415    RTERRINFOSTATIC StaticErrInfo;
     416    for (uint32_t i = 0; i < g_cBuildCerts; i++)
     417    {
     418        rc = RTCrStoreCertAddEncoded(State.RootStore.m_hStore, RTCRCERTCTX_F_ENC_X509_DER,
     419                                     g_aBuildCerts[i].pbCert, g_aBuildCerts[i].cbCert, RTErrInfoInitStatic(&StaticErrInfo));
     420        if (RT_FAILURE(rc))
     421            return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to add build cert #%u to root store: %Rrc%#RTeim",
     422                                  i, rc, &StaticErrInfo.Core);
     423    }
     424    uint32_t i = g_cTimestampRootCerts; /* avoids warning if g_cTimestampRootCerts is 0. */
     425    while (i-- > 0)
     426    {
     427        rc = RTCrStoreCertAddEncoded(State.RootStore.m_hStore, RTCRCERTCTX_F_ENC_X509_DER,
     428                                     g_aTimestampRootCerts[i].pbCert, g_aTimestampRootCerts[i].cbCert,
     429                                     RTErrInfoInitStatic(&StaticErrInfo));
     430        if (RT_FAILURE(rc))
     431            return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to add build timestamp root cert #%u to root store: %Rrc%#RTeim",
     432                                  i, rc, &StaticErrInfo.Core);
     433    }
     434
     435    /*
     436     * Open the executable image and verify it.
     437     */
     438    char *pszExePath = NULL;
     439    rc = RTUtf16ToUtf8(pwszExePath, &pszExePath);
     440    AssertRCReturn(rc, RTEXITCODE_FAILURE);
     441    RTLDRMOD hLdrMod;
     442    rc = RTLdrOpen(pszExePath, RTLDR_O_FOR_VALIDATION, RTLDRARCH_WHATEVER, &hLdrMod);
     443    if (RT_SUCCESS(rc))
     444    {
     445        State.pszFilename = pszExePath;
     446
     447        rc = RTLdrVerifySignature(hLdrMod, VerifyExeCallback, &State, RTErrInfoInitStatic(&StaticErrInfo));
     448        if (RT_FAILURE(rc))
     449            RTMsgError("RTLdrVerifySignature failed on '%s': %Rrc%#RTeim\n", pszExePath, rc, &StaticErrInfo.Core);
     450
     451        RTStrFree(pszExePath);
     452        RTLdrClose(hLdrMod);
     453
     454        if (RT_FAILURE(rc))
     455            return rc != VERR_LDRVI_NOT_SIGNED ? RTEXITCODE_FAILURE : RTEXITCODE_SKIPPED;
     456        if (State.cOkay > 0)
     457        {
     458            if (State.cTrustedCerts > 0)
     459                return RTEXITCODE_SUCCESS;
     460            RTMsgError("None of the build certificates were used for signing '%ls'!", pwszExePath);
     461        }
     462        return RTEXITCODE_FAILURE;
     463    }
     464    RTStrFree(pszExePath);
     465    return RTEXITCODE_FAILURE;
     466}
     467
     468# else /* Using Windows APIs */
    54469
    55470/**
     
    183598                                 NULL /*ppvContext*/))
    184599            rcExit = ErrorMsgRcSWSU(50 + i*4, "CryptQueryObject/FILE on '", aExes[i].pwszFile, "': ", GetLastError());
     600/** @todo this isn't getting us what we want. It's just accessing the
     601 *        certificates shipped with the signature. Sigh. */
    185602        else if (!pfnCryptMsgGetParam(aExes[i].hMsg, CMSG_CERT_PARAM, 0, NULL, &aExes[i].cbCert))
    186603            rcExit = ErrorMsgRcSWSU(51 + i*4, "CryptMsgGetParam/CMSG_CERT_PARAM/size failed on '",
     
    320737}
    321738
     739# endif /* Using Windows APIs. */
    322740#endif /* VBOX_SIGNING_MODE */
    323741
     
    6791097
    6801098#ifdef VBOX_SIGNING_MODE
     1099# if 1 /* Use the IPRT code as it it will work on all windows versions without trouble.
     1100          Added some 800KB to the executable, but so what. */
     1101    rcExit = CheckFileSignatureIprt(wszExePath);
     1102# else
    6811103    rcExit = CheckFileSignatures(wszExePath, hFileExe, wszSelfPath, hFileSelf);
     1104# endif
    6821105    if (rcExit != 0)
    6831106        return rcExit;
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