- Timestamp:
- Apr 5, 2016 10:44:40 AM (9 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r60243 r60328 2980 2980 </enum> 2981 2981 2982 <enum 2983 name="CertificateVersion" 2984 uuid="394b00ce-4b60-45ff-abe1-f58221d4f73b" 2985 > 2986 <desc> 2987 Possible version of certificate 2988 </desc> 2989 <const name="Unknown" value="0"/> 2990 <const name="One" value="1"/> 2991 <const name="Two" value="2"/> 2992 <const name="Three" value="3"/> 2993 <const name="Four" value="4"/> 2994 </enum> 2995 2982 2996 <!-- 2983 2997 // ICertificate … … 2993 3007 X509 certificate details. 2994 3008 </desc> 2995 <attribute name="versionNumber" type=" wstring" readonly="yes">2996 <desc>Certificate version .</desc>3009 <attribute name="versionNumber" type="CertificateVersion" readonly="yes"> 3010 <desc>Certificate version number.</desc> 2997 3011 </attribute> 2998 3012 <attribute name="serialNumber" type="wstring" readonly="yes"> … … 3055 3069 <desc>Set if the certificate is trusted.</desc> 3056 3070 </attribute> 3071 <attribute name="presence" type="boolean" readonly="yes"> 3072 <desc>Returns true in case of presence of certificate.</desc> 3073 </attribute> 3074 <attribute name="verified" type="boolean" readonly="yes"> 3075 <desc>Check whether certificate was verified or not during import.</desc> 3076 </attribute> 3057 3077 3058 3078 <method name="queryInfo"> … … 3060 3080 <param name="what" type="long" dir="in"/> 3061 3081 <param name="result" type="wstring" dir="return" /> 3062 </method>3063 3064 <method name="checkExistence">3065 <desc>3066 Check whether certificate exists or not in the OVF appliance.3067 </desc>3068 3069 <param name="presence" type="boolean" dir="return">3070 <desc>Returns true in case of presence of certificate.</desc>3071 </param>3072 </method>3073 3074 <method name="isVerified">3075 <desc>3076 Check whether certificate was verified or not during import.3077 </desc>3078 3079 <param name="verified" type="boolean" dir="return">3080 <desc>Returns true if certificate was verified.</desc>3081 </param>3082 3082 </method> 3083 3083 -
trunk/src/VBox/Main/include/CertificateImpl.h
r60246 r60328 19 19 #define ____H_CERTIFICATEIMPL 20 20 21 //#define DONT_DUPLICATE_ALL_THE_DATA22 23 21 /* VBox includes */ 24 22 #include <VBox/settings.h> … … 28 26 #include <vector> 29 27 30 31 28 using namespace std; 32 29 33 #ifndef DONT_DUPLICATE_ALL_THE_DATA34 /* VBox forward declarations */35 30 class Appliance; 36 #endif37 31 38 32 class ATL_NO_VTABLE Certificate : … … 44 38 DECLARE_EMPTY_CTOR_DTOR(Certificate) 45 39 46 #ifdef DONT_DUPLICATE_ALL_THE_DATA 40 HRESULT init(Appliance* appliance); 47 41 HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted); 48 #else49 HRESULT init(Appliance* appliance);50 #endif51 42 void uninit(); 52 43 … … 54 45 void FinalRelease(); 55 46 56 #ifndef DONT_DUPLICATE_ALL_THE_DATA57 HRESULT setData(RTCRX509CERTIFICATE const *inCert);58 #endif59 60 47 private: 61 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */62 48 const Appliance* m_appliance; 63 #endif64 65 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */66 HRESULT setVersionNumber(uint64_t inVersionNumber);67 HRESULT setSerialNumber(uint64_t inSerialNumber);68 HRESULT setPublicKeyAlgorithmOID(const char *aPublicKeyAlgorithmOID);69 HRESULT setPublicKeyAlgorithmName(const char *aPublicKeyAlgorithmOID);70 HRESULT setSignatureAlgorithmOID(const char *aSignatureAlgorithmOID);71 HRESULT setSignatureAlgorithmName(const char *aSignatureAlgorithmOID);72 HRESULT setIssuerName(com::Utf8Str &aIssuerName);73 HRESULT setSubjectName(com::Utf8Str &aSubjectName);74 HRESULT setValidityPeriodNotBefore(PCRTTIME aValidityPeriodNotBefore);75 HRESULT setValidityPeriodNotAfter(PCRTTIME aValidityPeriodNotAfter);76 HRESULT setCertificateAuthority(BOOL aCertificateAuthority);77 HRESULT setSelfSigned(BOOL aSelfSigned);78 HRESULT setTrusted(BOOL aTrusted);79 // HRESULT setSubjectPublicKey(std::vector<BYTE> aSubjectPublicKey);80 // HRESULT setIssuerUniqueIdentifier(std::vector<BYTE> aIssuerUniqueIdentifier);81 // HRESULT setSubjectUniqueIdentifier(std::vector<BYTE> aSubjectUniqueIdentifier);82 // HRESULT setKeyUsage(std::vector<ULONG> aKeyUsage);83 // HRESULT setExtendedKeyUsage(std::vector<com::Utf8Str> aExtendedKeyUsage);84 // HRESULT setRawCertData(std::vector<BYTE> aRawCertData);85 #endif86 49 87 50 // wrapped ICertificate properties 88 HRESULT getVersionNumber( com::Utf8Str &aVersionNumber);51 HRESULT getVersionNumber(CertificateVersion_T *aVersionNumber); 89 52 HRESULT getSerialNumber(com::Utf8Str &aSerialNumber); 90 53 HRESULT getSignatureAlgorithmOID(com::Utf8Str &aSignatureAlgorithmOID); … … 105 68 HRESULT getSelfSigned(BOOL *aSelfSigned); 106 69 HRESULT getTrusted(BOOL *aTrusted); 107 70 HRESULT getVerified(BOOL *aVerified); 71 HRESULT getPresence(BOOL *aPresence); 108 72 // wrapped ICertificate methods 109 73 HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult); 110 #ifndef DONT_DUPLICATE_ALL_THE_DATA111 HRESULT checkExistence(BOOL *aPresence);112 HRESULT isVerified(BOOL *aVerified);113 #endif114 74 115 #ifdef DONT_DUPLICATE_ALL_THE_DATA116 75 /** @name Methods extracting COM data from the certificate object 117 76 * @{ */ … … 122 81 HRESULT i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn); 123 82 /** @} */ 124 #endif 83 125 84 //data 126 85 struct Data; -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r60220 r60328 1716 1716 * digest that is encrypted with the certificate in the latter part. 1717 1717 */ 1718 bool lTrusted = false; 1719 1718 1720 if (m->pbSignedDigest) 1719 1721 { … … 1829 1831 if ( !m->SignerCert.TbsCertificate.T3.pBasicConstraints 1830 1832 || !m->SignerCert.TbsCertificate.T3.pBasicConstraints->CA.fValue) 1833 { 1831 1834 i_addWarning(tr("Self signed certificate used to sign '%s' is not marked as certificate authority (CA)"), 1832 1835 pTask->locInfo.strPath.c_str()); 1836 } 1837 else 1838 lTrusted = true; 1833 1839 } 1834 1840 else … … 1914 1920 else 1915 1921 hrc2 = setErrorVrc(vrc, "RTCrX509CertPathsSetValidTimeSpec failed: %Rrc", vrc); 1922 1923 if(RT_SUCCESS(vrc)) 1924 lTrusted = true; 1916 1925 } 1917 1926 else if (vrc == VERR_CR_X509_CPV_NO_TRUSTED_PATHS) … … 1952 1961 if(m->fSignerCertLoaded) 1953 1962 { 1954 pCertificateInfo-> setData(&m->SignerCert);1963 pCertificateInfo->initCertificate(&m->SignerCert, lTrusted); 1955 1964 } 1956 1965 -
trunk/src/VBox/Main/src-server/CertificateImpl.cpp
r60246 r60328 33 33 struct CertificateData 34 34 { 35 #ifdef DONT_DUPLICATE_ALL_THE_DATA36 35 CertificateData() 37 36 : fTrusted(false) … … 61 60 CertificateData(const CertificateData &rTodo) { AssertFailed(); NOREF(rTodo); } 62 61 CertificateData &operator=(const CertificateData &rTodo) { AssertFailed(); NOREF(rTodo); return *this; } 63 64 #else65 CertificateData() :66 mVersionNumber(0),67 mSerialNumber(0),68 mSelfSigned(FALSE),69 mTrusted(FALSE),70 mCertificateAuthority(FALSE)71 {}72 73 uint64_t mVersionNumber;74 uint64_t mSerialNumber;75 Utf8Str mSignatureAlgorithmOID;76 Utf8Str mSignatureAlgorithmName;77 Utf8Str mPublicKeyAlgorithmOID;78 Utf8Str mPublicKeyAlgorithmName;79 PCRTTIME mValidityPeriodNotBefore;80 PCRTTIME mValidityPeriodNotAfter;81 BOOL mSelfSigned;82 BOOL mTrusted;83 BOOL mCertificateAuthority;84 85 std::vector<Utf8Str> mIssuerName;86 std::vector<Utf8Str> mSubjectName;87 std::vector<BYTE> mSubjectPublicKey;88 std::vector<BYTE> mIssuerUniqueIdentifier;89 std::vector<BYTE> mSubjectUniqueIdentifier;90 std::vector<ULONG> mKeyUsage;91 std::vector<Utf8Str> mExtendedKeyUsage;92 std::vector<BYTE> mRawCertData;93 #endif94 62 }; 95 63 … … 98 66 Backupable<CertificateData> m; 99 67 }; 100 101 #ifndef DONT_DUPLICATE_ALL_THE_DATA102 const char* const strUnknownAlgorithm = "Unknown Algorithm";103 const char* const strRsaEncription = "rsaEncryption";104 const char* const strMd2WithRSAEncryption = "md2WithRSAEncryption";105 const char* const strMd4WithRSAEncryption = "md4WithRSAEncryption";106 const char* const strMd5WithRSAEncryption = "md5WithRSAEncryption";107 const char* const strSha1WithRSAEncryption = "sha1WithRSAEncryption";108 const char* const strSha256WithRSAEncryption = "sha256WithRSAEncryption";109 const char* const strSha384WithRSAEncryption = "sha384WithRSAEncryption";110 const char* const strSha512WithRSAEncryption = "sha512WithRSAEncryption";111 const char* const strSha224WithRSAEncryption = "sha224WithRSAEncryption";112 #endif113 68 114 69 /////////////////////////////////////////////////////////////////////////////////// … … 131 86 } 132 87 133 #ifdef DONT_DUPLICATE_ALL_THE_DATA 88 HRESULT Certificate::init(Appliance* appliance) 89 { 90 HRESULT rc = S_OK; 91 LogFlowThisFuncEnter(); 92 93 /* Enclose the state transition NotReady->InInit->Ready */ 94 AutoInitSpan autoInitSpan(this); 95 AssertReturn(autoInitSpan.isOk(), E_FAIL); 96 if(appliance!=NULL) 97 { 98 LogFlowThisFunc(("m_appliance: %d \n", m_appliance)); 99 m_appliance = appliance; 100 } 101 else 102 rc = E_FAIL; 103 104 /* Confirm a successful initialization when it's the case */ 105 if (SUCCEEDED(rc)) 106 autoInitSpan.setSucceeded(); 107 108 LogFlowThisFunc(("rc=%Rhrc\n", rc)); 109 LogFlowThisFuncLeave(); 110 111 return rc; 112 } 113 134 114 /** 135 115 * Initializes a certificate instance. … … 140 120 */ 141 121 HRESULT Certificate::initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted) 142 #else143 HRESULT Certificate::init(Appliance* appliance)144 #endif145 122 { 146 123 HRESULT rc = S_OK; 147 124 LogFlowThisFuncEnter(); 148 125 149 /* Enclose the state transition NotReady->InInit->Ready */150 AutoInitSpan autoInitSpan(this);151 AssertReturn(autoInitSpan.isOk(), E_FAIL);152 153 #ifndef DONT_DUPLICATE_ALL_THE_DATA154 if(appliance!=NULL)155 {156 LogFlowThisFunc(("m_appliance: %d \n", m_appliance));157 m_appliance = appliance;158 }159 else160 rc = E_FAIL;161 #endif162 163 126 mData = new Data(); 164 127 mData->m.allocate(); 165 #ifdef DONT_DUPLICATE_ALL_THE_DATA 128 166 129 int vrc = RTCrX509Certificate_Clone(&mData->m->X509, a_pCert, &g_RTAsn1DefaultAllocator); 167 130 if (RT_SUCCESS(vrc)) … … 172 135 else 173 136 rc = Global::vboxStatusCodeToCOM(vrc); 174 #else175 mData->m->mSignatureAlgorithmOID.setNull();176 mData->m->mSignatureAlgorithmName.setNull();177 mData->m->mPublicKeyAlgorithmOID.setNull();178 mData->m->mPublicKeyAlgorithmName.setNull();179 mData->m->mIssuerName.resize(0);180 mData->m->mSubjectName.resize(0);181 182 mData->m->mSubjectPublicKey.resize(0);183 mData->m->mIssuerUniqueIdentifier.resize(0);184 mData->m->mSubjectUniqueIdentifier.resize(0);185 mData->m->mKeyUsage.resize(0);186 mData->m->mExtendedKeyUsage.resize(0);187 mData->m->mRawCertData.resize(0);188 #endif189 190 /* Confirm a successful initialization when it's the case */191 if (SUCCEEDED(rc))192 autoInitSpan.setSucceeded();193 137 194 138 LogFlowThisFunc(("rc=%Rhrc\n", rc)); … … 210 154 } 211 155 212 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* We'll query the data from the RTCrX509* API. */213 214 /**215 * Public method implementation.216 * @param aSignatureAlgorithmOID217 * @return218 */219 HRESULT Certificate::setData(PCRTCRX509CERTIFICATE inCert)220 {221 222 /*set mData.m->mVersionNumber */223 setVersionNumber(inCert->TbsCertificate.T0.Version.uValue.u);224 225 /*set mData.m->mSerialNumber */226 setSerialNumber(inCert->TbsCertificate.SerialNumber.uValue.u);227 228 /*set mData.m->mValidityPeriodNotBefore */229 setValidityPeriodNotBefore(&inCert->TbsCertificate.Validity.NotBefore.Time);230 231 /*set mData.m->mValidityPeriodNotAfter */232 setValidityPeriodNotAfter(&inCert->TbsCertificate.Validity.NotAfter.Time);233 234 /*set mData.m->mPublicKeyAlgorithmOID and mData.m->mPublicKeyAlgorithmName*/235 setPublicKeyAlgorithmOID(inCert->TbsCertificate.SubjectPublicKeyInfo.Algorithm.Algorithm.szObjId);236 237 /*set mData.m->mSignatureAlgorithmOID and mData.m->mSignatureAlgorithmName*/238 setSignatureAlgorithmOID(inCert->TbsCertificate.Signature.Algorithm.szObjId);239 240 if ( inCert->TbsCertificate.T3.pBasicConstraints241 && inCert->TbsCertificate.T3.pBasicConstraints->CA.fValue)242 {243 /*set mData.m->mCertificateAuthority TRUE*/244 setCertificateAuthority(true);245 }246 247 if (RTCrX509Certificate_IsSelfSigned(inCert))248 {249 /*set mData.m->mSelfSigned TRUE*/250 setSelfSigned(true);251 }252 253 char szCharArray[512];254 szCharArray[sizeof(szCharArray) - 1] = '\0';255 256 /*257 * get inCert->TbsCertificate.Subject as string258 * and set mData.m->mSignatureAlgorithmName259 */260 RTCrX509Name_FormatAsString(&inCert->TbsCertificate.Subject, szCharArray, sizeof(szCharArray) - 1, NULL);261 com::Utf8Str aSubjectName = szCharArray;262 setSubjectName(aSubjectName);263 /*264 * get inCert->TbsCertificate.Issuer as string265 * and set mData.m->mSignatureAlgorithmName266 */267 RTCrX509Name_FormatAsString(&inCert->TbsCertificate.Issuer, szCharArray, sizeof(szCharArray) - 1, NULL);268 com::Utf8Str aIssuerName = szCharArray;269 setIssuerName(aIssuerName);270 271 return S_OK;272 }273 274 /**275 * Public method implementation.276 * @param aSignatureAlgorithmOID277 * @return278 */279 HRESULT Certificate::setSignatureAlgorithmName(const char *aSignatureAlgorithmOID)280 {281 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);282 283 HRESULT rc = S_OK;284 const char *actualName = strUnknownAlgorithm;285 286 if (aSignatureAlgorithmOID == NULL)287 rc = E_FAIL;288 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_MD2_WITH_RSA))289 actualName = strMd2WithRSAEncryption;290 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_MD4_WITH_RSA))291 actualName = strMd4WithRSAEncryption;292 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_MD5_WITH_RSA))293 actualName = strMd5WithRSAEncryption;294 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_SHA1_WITH_RSA))295 actualName = strSha1WithRSAEncryption;296 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_SHA224_WITH_RSA))297 actualName = strSha224WithRSAEncryption;298 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_SHA256_WITH_RSA))299 actualName = strSha256WithRSAEncryption;300 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_SHA384_WITH_RSA))301 actualName = strSha384WithRSAEncryption;302 else if(!strcmp(aSignatureAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_SHA512_WITH_RSA))303 actualName = strSha512WithRSAEncryption;304 else305 {306 rc = E_FAIL;307 }308 309 mData->m->mSignatureAlgorithmName = actualName;310 311 if(FAILED(rc))312 Log1Warning(("Can't find an appropriate signature algorithm name for given OID %s", aSignatureAlgorithmOID));313 314 return rc;315 316 }317 318 /**319 * Public method implementation.320 * @param aSignatureAlgorithmOID321 * @return322 */323 HRESULT Certificate::setSignatureAlgorithmOID(const char *aSignatureAlgorithmOID)324 {325 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);326 327 mData->m->mSignatureAlgorithmOID = aSignatureAlgorithmOID;328 329 setSignatureAlgorithmName(mData->m->mSignatureAlgorithmOID.c_str());330 331 return S_OK;332 }333 334 /**335 * Private method implementation.336 * @param aPublicKeyAlgorithm337 * @return338 */339 HRESULT Certificate::setPublicKeyAlgorithmName(const char *aPublicKeyAlgorithmOID)340 {341 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);342 343 HRESULT rc = S_OK;344 const char *foundName = strUnknownAlgorithm;345 346 if (!strcmp(aPublicKeyAlgorithmOID, RTCRX509ALGORITHMIDENTIFIERID_RSA))347 foundName = strRsaEncription;348 else349 {350 rc = E_FAIL;351 }352 353 mData->m->mPublicKeyAlgorithmName = foundName;354 355 if(FAILED(rc))356 Log1Warning(("Can't find an appropriate public key name for given OID %s", aPublicKeyAlgorithmOID));357 358 return rc;359 }360 361 362 /**363 * Private method implementation.364 * @param aPublicKeyAlgorithmOID365 * @return366 */367 HRESULT Certificate::setPublicKeyAlgorithmOID(const char *aPublicKeyAlgorithmOID)368 {369 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);370 371 mData->m->mPublicKeyAlgorithmOID = aPublicKeyAlgorithmOID;372 373 setPublicKeyAlgorithmName(mData->m->mPublicKeyAlgorithmOID.c_str());374 375 return S_OK;376 }377 378 /**379 * Public method implementation.380 * @param inVersionNumber381 * @return382 */383 HRESULT Certificate::setVersionNumber(uint64_t inVersionNumber)384 {385 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);386 387 mData->m->mVersionNumber = inVersionNumber;388 389 return S_OK;390 }391 392 /**393 * Public method implementation.394 * @param inVersionNumber395 * @return396 */397 HRESULT Certificate::setSerialNumber(uint64_t inSerialNumber)398 {399 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);400 401 mData->m->mSerialNumber = inSerialNumber;402 403 return S_OK;404 }405 406 /**407 * Public method implementation.408 * @param aCertificateAuthority409 * @return410 */411 HRESULT Certificate::setCertificateAuthority(BOOL aCertificateAuthority)412 {413 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);414 415 mData->m->mCertificateAuthority = aCertificateAuthority;416 417 return S_OK;418 }419 420 /**421 * Public method implementation.422 * @param aIssuerName423 * @return424 */425 HRESULT Certificate::setIssuerName(com::Utf8Str &aIssuerName)426 {427 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);428 429 RTCList<RTCString> l_IssueNameAsList = aIssuerName.split(",");430 uint32_t l_sz = l_IssueNameAsList.size();431 if(l_sz!=0)432 mData->m->mIssuerName.clear();433 for(uint32_t i = 0; i<l_sz; ++i)434 mData->m->mIssuerName.push_back(l_IssueNameAsList[i]);435 436 return S_OK;437 }438 439 /**440 * Public method implementation.441 * @param aSubjectName442 * @return443 */444 HRESULT Certificate::setSubjectName(com::Utf8Str &aSubjectName)445 {446 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);447 448 RTCList<RTCString> l_SubjectNameAsList = aSubjectName.split(",");449 uint32_t l_sz = l_SubjectNameAsList.size();450 if(l_sz!=0)451 mData->m->mSubjectName.clear();452 for(uint32_t i = 0; i<l_sz; ++i)453 mData->m->mSubjectName.push_back(l_SubjectNameAsList[i]);454 455 return S_OK;456 }457 458 /**459 * Public method implementation.460 * @param aSelfSigned461 * @return462 */463 HRESULT Certificate::setSelfSigned(BOOL aSelfSigned)464 {465 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);466 467 mData->m->mSelfSigned = aSelfSigned;468 469 return S_OK;470 }471 472 /**473 * Public method implementation.474 * @param aTrusted475 * @return476 */477 HRESULT Certificate::setTrusted(BOOL aTrusted)478 {479 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);480 481 mData->m->mTrusted = aTrusted;482 483 return S_OK;484 }485 486 /**487 * Public method implementation.488 * @param aValidityPeriodNotBefore489 * @return490 */491 HRESULT Certificate::setValidityPeriodNotBefore(PCRTTIME aValidityPeriodNotBefore)492 {493 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);494 495 mData->m->mValidityPeriodNotBefore = aValidityPeriodNotBefore;496 497 return S_OK;498 }499 500 /**501 * Public method implementation.502 * @param aValidityPeriodNotAfter503 * @return504 */505 HRESULT Certificate::setValidityPeriodNotAfter(PCRTTIME aValidityPeriodNotAfter)506 {507 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);508 509 mData->m->mValidityPeriodNotAfter = aValidityPeriodNotAfter;510 511 return S_OK;512 }513 514 #endif /* !DONT_DUPLICATE_ALL_THE_DATA */515 516 156 /** 517 157 * Private method implementation. … … 519 159 * @return 520 160 */ 521 HRESULT Certificate::getVersionNumber( com::Utf8Str &aVersionNumber)522 { 523 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 524 #ifdef DONT_DUPLICATE_ALL_THE_DATA 161 HRESULT Certificate::getVersionNumber(CertificateVersion_T *aVersionNumber) 162 { 163 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 164 525 165 Assert(mData->m->fValidX509); 526 166 /** @todo make this ULONG, or better, an ENUM. */ 527 aVersionNumber = Utf8StrFmt("%RU64", mData->m->X509.TbsCertificate.T0.Version.uValue.u + 1); /* version 1 has value 0, so +1.*/528 #else 529 Utf8StrFmt strVer("%Lu", mData->m->mVersionNumber); 530 aVersionNumber = strVer;531 #endif 167 //aVersionNumber = Utf8StrFmt("%RU64", mData->m->X509.TbsCertificate.T0.Version.uValue.u + 1); */ 168 /* version 1 has value 0, so +1.*/ 169 170 *aVersionNumber = mData->m->X509.TbsCertificate.T0.Version.uValue.u + 1; 171 532 172 return S_OK; 533 173 } … … 541 181 { 542 182 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 543 #ifdef DONT_DUPLICATE_ALL_THE_DATA 183 544 184 Assert(mData->m->fValidX509); 545 185 … … 550 190 else 551 191 return Global::vboxStatusCodeToCOM(vrc); 552 #else 553 Utf8StrFmt strVer("%llx", mData->m->mSerialNumber); 554 aSerialNumber = strVer; 555 #endif 192 556 193 return S_OK; 557 194 } … … 565 202 { 566 203 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 567 #ifdef DONT_DUPLICATE_ALL_THE_DATA 204 568 205 Assert(mData->m->fValidX509); 569 206 aSignatureAlgorithmOID = mData->m->X509.TbsCertificate.Signature.Algorithm.szObjId; 570 #else 571 aSignatureAlgorithmOID = mData->m->mSignatureAlgorithmOID; 572 #endif 207 573 208 return S_OK; 574 209 } … … 582 217 { 583 218 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 584 #ifdef DONT_DUPLICATE_ALL_THE_DATA 219 585 220 Assert(mData->m->fValidX509); 586 221 return i_getAlgorithmName(&mData->m->X509.TbsCertificate.Signature, aSignatureAlgorithmName); 587 #else588 aSignatureAlgorithmName = mData->m->mSignatureAlgorithmName;589 590 return S_OK;591 #endif592 222 } 593 223 … … 600 230 { 601 231 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 602 #ifdef DONT_DUPLICATE_ALL_THE_DATA 232 603 233 Assert(mData->m->fValidX509); 604 234 return i_getX509Name(&mData->m->X509.TbsCertificate.Issuer, aIssuerName); 605 #else606 aIssuerName = mData->m->mIssuerName;607 608 return S_OK;609 #endif610 235 } 611 236 … … 618 243 { 619 244 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 620 #ifdef DONT_DUPLICATE_ALL_THE_DATA 245 621 246 Assert(mData->m->fValidX509); 622 247 return i_getX509Name(&mData->m->X509.TbsCertificate.Subject, aSubjectName); 623 #else624 625 aSubjectName = mData->m->mSubjectName;626 627 return S_OK;628 #endif629 248 } 630 249 … … 637 256 { 638 257 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 639 #ifdef DONT_DUPLICATE_ALL_THE_DATA 258 640 259 Assert(mData->m->fValidX509); 641 260 return i_getTime(&mData->m->X509.TbsCertificate.Validity.NotBefore, aValidityPeriodNotBefore); 642 #else643 HRESULT rc = S_OK;644 645 size_t arrSize = 40;646 char* charArr = new char[arrSize];647 char* strTimeFormat = RTTimeToString(mData->m->mValidityPeriodNotBefore, charArr, arrSize);648 649 if (strTimeFormat == NULL)650 {651 rc=E_FAIL;652 }653 654 aValidityPeriodNotBefore = charArr;655 delete[] charArr;656 657 return rc;658 #endif659 261 } 660 262 … … 667 269 { 668 270 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 669 #ifdef DONT_DUPLICATE_ALL_THE_DATA 271 670 272 Assert(mData->m->fValidX509); 671 273 return i_getTime(&mData->m->X509.TbsCertificate.Validity.NotAfter, aValidityPeriodNotAfter); 672 #else673 674 HRESULT rc = S_OK;675 size_t arrSize = 40;676 char* charArr = new char[arrSize];677 char* strTimeFormat = RTTimeToString(mData->m->mValidityPeriodNotAfter, charArr, arrSize);678 679 if (strTimeFormat == NULL)680 {681 rc = E_FAIL;682 }683 684 aValidityPeriodNotAfter = charArr;685 delete[] charArr;686 return rc;687 #endif688 274 } 689 275 … … 691 277 { 692 278 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 693 #ifdef DONT_DUPLICATE_ALL_THE_DATA 279 694 280 Assert(mData->m->fValidX509); 695 281 aPublicKeyAlgorithmOID = mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.Algorithm.Algorithm.szObjId; 696 282 return S_OK; 697 #else698 return E_NOTIMPL;699 #endif700 283 } 701 284 … … 708 291 { 709 292 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 710 #ifdef DONT_DUPLICATE_ALL_THE_DATA 293 711 294 Assert(mData->m->fValidX509); 712 295 return i_getAlgorithmName(&mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.Algorithm, aPublicKeyAlgorithm); 713 #else714 aPublicKeyAlgorithm = mData->m->mPublicKeyAlgorithmName;715 716 return S_OK;717 #endif718 296 } 719 297 … … 725 303 HRESULT Certificate::getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey) 726 304 { 727 #ifdef DONT_DUPLICATE_ALL_THE_DATA 305 728 306 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Getting encoded ASN.1 bytes may make changes to X509. */ 729 307 return i_getEncodedBytes(&mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.Asn1Core, aSubjectPublicKey); 730 #else731 return E_NOTIMPL;732 #endif733 308 } 734 309 … … 741 316 { 742 317 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 743 #ifdef DONT_DUPLICATE_ALL_THE_DATA 318 744 319 return i_getUniqueIdentifier(&mData->m->X509.TbsCertificate.T1.IssuerUniqueId, aIssuerUniqueIdentifier); 745 #else746 return E_NOTIMPL;747 #endif748 320 } 749 321 … … 756 328 { 757 329 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 758 #ifdef DONT_DUPLICATE_ALL_THE_DATA 330 759 331 return i_getUniqueIdentifier(&mData->m->X509.TbsCertificate.T2.SubjectUniqueId, aSubjectUniqueIdentifier); 760 #else761 return E_NOTIMPL;762 #endif763 332 } 764 333 … … 771 340 { 772 341 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 773 #ifdef DONT_DUPLICATE_ALL_THE_DATA 342 774 343 *aCertificateAuthority = mData->m->X509.TbsCertificate.T3.pBasicConstraints 775 344 && mData->m->X509.TbsCertificate.T3.pBasicConstraints->CA.fValue; 776 #else 777 *aCertificateAuthority = mData->m->mCertificateAuthority; 778 #endif 345 779 346 return S_OK; 780 347 } … … 788 355 { 789 356 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 790 #ifdef DONT_DUPLICATE_ALL_THE_DATA 357 791 358 *aKeyUsage = mData->m->X509.TbsCertificate.T3.fKeyUsage; 792 359 return S_OK; 793 #else794 return E_NOTIMPL;795 #endif796 360 } 797 361 … … 815 379 HRESULT Certificate::getRawCertData(std::vector<BYTE> &aRawCertData) 816 380 { 817 #ifdef DONT_DUPLICATE_ALL_THE_DATA818 381 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Getting encoded ASN.1 bytes may make changes to X509. */ 819 382 return i_getEncodedBytes(&mData->m->X509.SeqCore.Asn1Core, aRawCertData); 820 #else821 return E_NOTIMPL;822 #endif823 383 } 824 384 … … 831 391 { 832 392 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 833 #ifdef DONT_DUPLICATE_ALL_THE_DATA 393 834 394 Assert(mData->m->fValidX509); 835 395 *aSelfSigned = RTCrX509Certificate_IsSelfSigned(&mData->m->X509); 836 #else 837 *aSelfSigned = mData->m->mSelfSigned; 838 #endif 396 839 397 return S_OK; 840 398 } … … 848 406 { 849 407 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 850 #ifdef DONT_DUPLICATE_ALL_THE_DATA 408 851 409 *aTrusted = mData->m->fTrusted; 852 #else 853 *aTrusted = mData->m->mTrusted; 854 #endif 410 855 411 return S_OK; 856 412 } … … 870 426 } 871 427 872 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* These are out of place. */ 873 874 /** 875 * Private method implementation. 428 /** 429 * Private method implementation. 876 430 * @param aPresence 877 431 * @return aPresence 878 432 */ 879 HRESULT Certificate:: checkExistence(BOOL *aPresence)433 HRESULT Certificate::getPresence(BOOL *aPresence) 880 434 { 881 435 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 887 441 888 442 /** 889 * Private method implementation. 890 * @param aVerified 443 * Private method implementation. 444 * @param aVerified 891 445 * @return aVerified 892 446 */ 893 HRESULT Certificate:: isVerified(BOOL *aVerified)447 HRESULT Certificate::getVerified(BOOL *aVerified) 894 448 { 895 449 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 901 455 return S_OK; 902 456 } 903 904 #else /* DONT_DUPLICATE_ALL_THE_DATA */905 457 906 458 HRESULT Certificate::i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn) … … 1009 561 } 1010 562 1011 #endif /* DONT_DUPLICATE_ALL_THE_DATA */ 1012 563
Note:
See TracChangeset
for help on using the changeset viewer.