Changeset 101647 in vbox for trunk/src/VBox/Runtime/tools/RTSignTool.cpp
- Timestamp:
- Oct 30, 2023 9:34:56 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/tools/RTSignTool.cpp
r100442 r101647 1073 1073 } 1074 1074 1075 /** 1076 * Adds trusted self-signed certificates from the system. 1077 * 1078 * @returns boolean success indicator. 1079 */ 1080 bool addIntermediateCertsFromSystem(PRTERRINFOSTATIC pStaticErrInfo) 1081 { 1082 bool fRc = true; 1083 RTCRSTOREID const s_aenmStoreIds[] = { RTCRSTOREID_SYSTEM_INTERMEDIATE_CAS, RTCRSTOREID_USER_INTERMEDIATE_CAS }; 1084 for (size_t i = 0; i < RT_ELEMENTS(s_aenmStoreIds); i++) 1085 { 1086 CryptoStore Tmp; 1087 int rc = RTCrStoreCreateSnapshotById(&Tmp.m_hStore, s_aenmStoreIds[i], RTErrInfoInitStatic(pStaticErrInfo)); 1088 if (RT_SUCCESS(rc)) 1089 { 1090 RTCRSTORECERTSEARCH Search; 1091 rc = RTCrStoreCertFindAll(Tmp.m_hStore, &Search); 1092 if (RT_SUCCESS(rc)) 1093 { 1094 PCRTCRCERTCTX pCertCtx; 1095 while ((pCertCtx = RTCrStoreCertSearchNext(Tmp.m_hStore, &Search)) != NULL) 1096 { 1097 /* Skip selfsigned certs as they're useless as intermediate certs (IIRC). */ 1098 if ( pCertCtx->pCert 1099 && !RTCrX509Certificate_IsSelfSigned(pCertCtx->pCert)) 1100 { 1101 int rc2 = RTCrStoreCertAddEncoded(this->m_hStore, 1102 pCertCtx->fFlags | RTCRCERTCTX_F_ADD_IF_NOT_FOUND, 1103 pCertCtx->pabEncoded, pCertCtx->cbEncoded, NULL); 1104 if (RT_FAILURE(rc2)) 1105 RTMsgWarning("RTCrStoreCertAddEncoded failed for a certificate: %Rrc", rc2); 1106 } 1107 RTCrCertCtxRelease(pCertCtx); 1108 } 1109 1110 int rc2 = RTCrStoreCertSearchDestroy(Tmp.m_hStore, &Search); 1111 AssertRC(rc2); 1112 } 1113 else 1114 { 1115 RTMsgError("RTCrStoreCertFindAll/%d failed: %Rrc", s_aenmStoreIds[i], rc); 1116 fRc = false; 1117 } 1118 } 1119 else 1120 { 1121 RTMsgError("RTCrStoreCreateSnapshotById/%d failed: %Rrc%#RTeim", s_aenmStoreIds[i], rc, &pStaticErrInfo->Core); 1122 fRc = false; 1123 } 1124 } 1125 return fRc; 1126 } 1127 1075 1128 }; 1076 1129 … … 3588 3641 if (RT_SUCCESS(rc)) 3589 3642 { 3643 /* Seems we might need this for the sha-1 certs and such. */ 3644 RTCrX509CertPathsSetValidTimeSpec(hCertPaths, NULL); 3645 3590 3646 /* Build the paths: */ 3591 3647 rc = RTCrX509CertPathsBuild(hCertPaths, RTErrInfoInitStatic(pStaticErrInfo)); … … 3710 3766 RTStrmWrappedPrintf(pStrm, RTSTRMWRAPPED_F_HANGING_INDENT, 3711 3767 "extract-%s-root [-v|--verbose] [-q|--quiet] [--signature-index|-i <num>] [--root <root-cert.der>] " 3712 "[--self-signed-roots-from-system] [--additional <supp-cert.der>] "3768 "[--self-signed-roots-from-system] [--additional <supp-cert.der>] [--intermediate-certs-from-system] " 3713 3769 "[--input] <signed-file> [-f|--force] [--output|-o] <outfile.cer>\n", 3714 3770 fTimestamp ? "timestamp" : "signer"); … … 3734 3790 "The file format can be PEM or DER.\n" 3735 3791 " -R, --self-signed-roots-from-system\n" 3736 " Use all self-signed trusted root certificates found in the system and associated with the "3792 " Use all self-signed trusted root certificates found on the system and associated with the " 3737 3793 "current user as trusted roots. This is limited to self-signed certificates, so that we get " 3738 3794 "a full chain even if a non-end-entity certificate is present in any of those system stores for " … … 3741 3797 " Use the certificate(s) in the specified file as a untrusted intermediate certificates. " 3742 3798 "The file format can be PEM or DER.\n" 3799 " -A, --intermediate-certs-from-system\n" 3800 " Use all certificates found on the system and associated with the current user as intermediate " 3801 "certification authorities.\n" 3743 3802 " --input <signed-file>\n" 3744 3803 " Signed executable or security cabinet file to examine. The '--input' option bit is optional " … … 3764 3823 { "--self-signed-roots-from-system", 'R', RTGETOPT_REQ_NOTHING }, 3765 3824 { "--additional", 'a', RTGETOPT_REQ_STRING }, 3825 { "--intermediate-certs-from-system",'A', RTGETOPT_REQ_NOTHING }, 3766 3826 { "--add", 'a', RTGETOPT_REQ_STRING }, 3767 3827 { "--input", 'I', RTGETOPT_REQ_STRING }, … … 3787 3847 case 'a': 3788 3848 if (!State.AdditionalStore.addFromFile(ValueUnion.psz, &StaticErrInfo)) 3849 return RTEXITCODE_FAILURE; 3850 break; 3851 3852 case 'A': 3853 if (!State.AdditionalStore.addIntermediateCertsFromSystem(&StaticErrInfo)) 3789 3854 return RTEXITCODE_FAILURE; 3790 3855 break;
Note:
See TracChangeset
for help on using the changeset viewer.