Changeset 105127 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jul 3, 2024 10:18:33 PM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 163757
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VRDEServerImpl.cpp
r105124 r105127 290 290 * @note Locks this object for writing. 291 291 */ 292 int VRDEServer::certificateRepair(BOOL &certificateGenerated) 293 { 294 int vrc = VINF_SUCCESS; 292 HRESULT VRDEServer::i_certificateRepair(BOOL &certificateGenerated) 293 { 295 294 if ( (mData->mapProperties["Security/Method"] != "RDP" || mData->mapProperties["Security/Method"] != "None")) 296 295 { 297 296 Utf8Str strServerCertificate("VRDEAutoGeneratedCert.pem"); 298 vrc = mParent->i_calculateFullPath(strServerCertificate, strServerCertificate);299 AssertRCReturn(vrc, vrc);297 int vrc = mParent->i_calculateFullPath(strServerCertificate, strServerCertificate); 298 AssertRCReturn(vrc, VBOX_E_IPRT_ERROR); 300 299 301 300 Utf8Str strServerPrivateKey("VRDEAutoGeneratedPrivateKey.pem"); 302 301 vrc = mParent->i_calculateFullPath(strServerPrivateKey, strServerPrivateKey); 303 AssertRCReturn(vrc, vrc);302 AssertRCReturn(vrc, VBOX_E_IPRT_ERROR); 304 303 305 304 if ( RTFileExists(strServerPrivateKey.c_str()) && RTFileExists(strServerCertificate.c_str()) ) 306 305 { 307 306 /* Check validity of certificate */ 308 RTCRX509CERTIFICATE pCertificate; 309 BOOL validCert = false; 310 vrc = RTCrX509Certificate_ReadFromFile(&pCertificate, strServerCertificate.c_str(), RTCRX509CERT_READ_F_PEM_ONLY, 307 RTCRX509CERTIFICATE certificate; 308 vrc = RTCrX509Certificate_ReadFromFile(&certificate, strServerCertificate.c_str(), RTCRX509CERT_READ_F_PEM_ONLY, 311 309 &g_RTAsn1DefaultAllocator, NULL); 312 310 if(RT_FAILURE(vrc)) 313 311 { 314 RTCrX509Certificate_Delete(& pCertificate);312 RTCrX509Certificate_Delete(&certificate); 315 313 return setError(VBOX_E_IPRT_ERROR, tr("Failed to read server certificate: (%Rrc)\n"), vrc); 316 314 } 317 315 318 316 RTTIMESPEC Now; 319 if ( RTCrX509Validity_IsValidAtTimeSpec(&(&pCertificate)->TbsCertificate.Validity, RTTimeNow(&Now)) ) 320 validCert = true; 321 322 RTCrX509Certificate_Delete(&pCertificate); 317 bool const validCert = RTCrX509Validity_IsValidAtTimeSpec(&certificate.TbsCertificate.Validity, RTTimeNow(&Now)); 318 319 RTCrX509Certificate_Delete(&certificate); 323 320 324 321 Utf8Str strPath = mData->mapProperties["Security/ServerCertificate"]; … … 336 333 alock.release(); 337 334 certificateGenerated = true; 338 RTCrX509Certificate_Delete(&pCertificate);339 335 } 340 336 else if ( (strPath.isEmpty() || strstr(strPath.c_str(),"VRDEAutoGeneratedCert.pem")) && !validCert) … … 346 342 if (RT_FAILURE(vrc)) 347 343 { 348 RTCrX509Certificate_Delete(&pCertificate);349 344 i_rollback(); 350 345 return setError(VBOX_E_IPRT_ERROR, tr("Failed to auto generate server key and certificate: (%Rrc)\n"), vrc); … … 395 390 } 396 391 } 397 return vrc;392 return S_OK; 398 393 } 399 394 … … 436 431 { 437 432 BOOL certificateGenerated = false; 438 int vrc = certificateRepair(certificateGenerated);433 int vrc = i_certificateRepair(certificateGenerated); 439 434 if (RT_FAILURE(vrc)) 440 435 LogRel((("Failed to auto generate server key and certificate: (%Rrc)\n"), vrc)); … … 634 629 { 635 630 BOOL certificateGenerated = false; 636 int vrc = certificateRepair(certificateGenerated);631 int vrc = i_certificateRepair(certificateGenerated); 637 632 if ( RT_FAILURE(vrc) ) 638 633 LogRel((("Failed to auto generate server key and certificate: (%Rrc)\n"), vrc));
Note:
See TracChangeset
for help on using the changeset viewer.