Changeset 51734 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 26, 2014 9:28:58 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r51733 r51734 77 77 static int checkCertificates(RTHTTP pHttp, const QString &strFullCertificateFileName); 78 78 static int downloadCertificates(RTHTTP pHttp, const QString &strFullCertificateFileName); 79 static int downloadCertificatePca3G5(RTHTTP pHttp, Q File &file);80 static int downloadCertificatePca3(RTHTTP pHttp, Q File &file);79 static int downloadCertificatePca3G5(RTHTTP pHttp, QByteArray &certificate); 80 static int downloadCertificatePca3(RTHTTP pHttp, QByteArray &certificate); 81 81 static int verifyCertificatePca3G5(RTHTTP pHttp, QByteArray &certificate); 82 82 static int verifyCertificatePca3(RTHTTP pHttp, QByteArray &certificate); 83 83 static int verifyCertificate(RTHTTP pHttp, QByteArray &certificate, const QByteArray &sha1, const QByteArray &sha512); 84 static int saveCertificates(const QString &strFullCertificateFileName, const QByteArray &certificatePca3G5, const QByteArray &certificatePca3); 84 85 static int saveCertificate(QFile &file, const QByteArray &certificate); 85 86 … … 356 357 int UINetworkReplyPrivateThread::downloadCertificates(RTHTTP pHttp, const QString &strFullCertificateFileName) 357 358 { 358 /* Open certificates file: */ 359 QFile file(strFullCertificateFileName); 360 bool fFileOpened = file.open(QIODevice::WriteOnly); 361 int rc = fFileOpened ? VINF_SUCCESS : VERR_OPEN_FAILED; 359 /* Prepare certificates: */ 360 QByteArray certificatePca3G5; 361 QByteArray certificatePca3; 362 /* Prepare result: */ 363 int rc = VINF_SUCCESS; 362 364 363 365 /* Download PCA-3G5 certificate: */ 364 366 if (RT_SUCCESS(rc)) 365 rc = downloadCertificatePca3G5(pHttp, file);367 rc = downloadCertificatePca3G5(pHttp, certificatePca3G5); 366 368 /* Download PCA-3 certificate: */ 367 369 if (RT_SUCCESS(rc)) 368 rc = downloadCertificatePca3(pHttp, file);369 370 /* Close certificates file: */371 if ( fFileOpened)372 file.close();370 rc = downloadCertificatePca3(pHttp, certificatePca3); 371 372 /* Save certificates: */ 373 if (RT_SUCCESS(rc)) 374 saveCertificates(strFullCertificateFileName, certificatePca3G5, certificatePca3); 373 375 374 376 /* Return result-code: */ … … 377 379 378 380 /* static */ 379 int UINetworkReplyPrivateThread::downloadCertificatePca3G5(RTHTTP pHttp, Q File &file)381 int UINetworkReplyPrivateThread::downloadCertificatePca3G5(RTHTTP pHttp, QByteArray &certificate) 380 382 { 381 383 /* Receive certificate: */ 382 QByteArray certificate;383 384 const QNetworkRequest address(QUrl("http://www.verisign.com/repository/roots/root-certificates/PCA-3G5.pem")); 384 385 int rc = performGetRequestForText(pHttp, address, certificate); … … 388 389 rc = verifyCertificatePca3G5(pHttp, certificate); 389 390 390 /* Save certificate: */391 if (RT_SUCCESS(rc))392 rc = saveCertificate(file, certificate);393 394 391 /* Return result-code: */ 395 392 return rc; … … 397 394 398 395 /* static */ 399 int UINetworkReplyPrivateThread::downloadCertificatePca3(RTHTTP pHttp, Q File &file)396 int UINetworkReplyPrivateThread::downloadCertificatePca3(RTHTTP pHttp, QByteArray &certificate) 400 397 { 401 398 /* Receive certificate: */ 402 QByteArray certificate;403 399 const QNetworkRequest address(QUrl("http://www.verisign.com/repository/roots/root-certificates/PCA-3.pem")); 404 400 int rc = performGetRequestForText(pHttp, address, certificate); … … 407 403 if (RT_SUCCESS(rc)) 408 404 rc = verifyCertificatePca3(pHttp, certificate); 409 410 /* Save certificate: */411 if (RT_SUCCESS(rc))412 rc = saveCertificate(file, certificate);413 405 414 406 /* Return result-code: */ … … 500 492 RTMemFree(abSha1); 501 493 RTMemFree(abSha512); 494 495 /* Return result-code: */ 496 return rc; 497 } 498 499 /* static */ 500 int UINetworkReplyPrivateThread::saveCertificates(const QString &strFullCertificateFileName, 501 const QByteArray &certificatePca3G5, 502 const QByteArray &certificatePca3) 503 { 504 /* Open certificates file: */ 505 QFile file(strFullCertificateFileName); 506 bool fFileOpened = file.open(QIODevice::WriteOnly); 507 int rc = fFileOpened ? VINF_SUCCESS : VERR_OPEN_FAILED; 508 509 /* Save certificates: */ 510 if (RT_SUCCESS(rc)) 511 rc = saveCertificate(file, certificatePca3G5); 512 if (RT_SUCCESS(rc)) 513 rc = saveCertificate(file, certificatePca3); 514 515 /* Close certificates file: */ 516 if (fFileOpened) 517 file.close(); 502 518 503 519 /* Return result-code: */
Note:
See TracChangeset
for help on using the changeset viewer.