VirtualBox

Ignore:
Timestamp:
Oct 17, 2013 9:09:08 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: back out r89941 and force re-downloading of the certs if we have 3 certs stored

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r49123 r49158  
    695695        src/wizards/firstrun/UIWizardFirstRunPageBasic.cpp
    696696
    697 ifndef VBOX_OSE
    698  VirtualBox_SOURCES += \
    699         src/net/Intermediate.cpp
    700 endif
    701 
    702697VirtualBox_SOURCES.darwin += \
    703698        src/platform/darwin/UIAbstractDockIconPreview.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp

    r49105 r49158  
    8080    static int verifyCertificatePca3G5(RTHTTP pHttp, QByteArray &certificate);
    8181    static int verifyCertificatePca3(RTHTTP pHttp, QByteArray &certificate);
    82     static int verifyCertificatePca3IntG3(RTHTTP pHttp, QByteArray &certificate);
    8382    static int verifyCertificate(RTHTTP pHttp, QByteArray &certificate, const QByteArray &sha1, const QByteArray &sha512);
    8483    static int saveCertificate(QFile &file, const QByteArray &certificate);
     
    292291        QString strData(file.readAll());
    293292#ifdef Q_WS_WIN
    294         QRegExp regExp("(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\r\\n]+-{5}END CERTIFICATE-{5})\\r\\n"
    295 # ifndef VBOX_OSE
    296                        "(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\r\\n]+-{5}END CERTIFICATE-{5})\\r\\n"
    297 # endif
    298                        "(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\r\\n]+-{5}END CERTIFICATE-{5})");
    299 #else /* Q_WS_WIN */
    300         QRegExp regExp("(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\n]+-{5}END CERTIFICATE-{5})\\n"
    301 # ifndef VBOX_OSE
    302                        "(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\n]+-{5}END CERTIFICATE-{5})\\n"
    303 # endif
    304                        "(-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\n]+-{5}END CERTIFICATE-{5})");
    305 #endif /* !Q_WS_WIN */
     293# define CERT   "-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\r\\n]+-{5}END CERTIFICATE-{5}"
     294# define REOLD  "(" CERT ")\\r\\n(" CERT ")\\r\\n(" CERT ")"
     295# define RENEW  "(" CERT ")\\r\\n(" CERT ")"
     296#else
     297# define CERT   "-{5}BEGIN CERTIFICATE-{5}[\\s\\S\\n]+-{5}END CERTIFICATE-{5}"
     298# define REOLD  "(" CERT ")\\n(" CERT ")\\n(" CERT ")"
     299# define RENEW  "(" CERT ")\\n(" CERT ")"
     300#endif
     301        /* First check if we have the old format with three certificates: */
     302        QRegExp regExp(REOLD);
    306303        regExp.setMinimal(true);
    307         int iIndex = regExp.indexIn(strData);
    308         if (iIndex == -1)
    309             rc = VERR_FILE_IO_ERROR;
     304
     305        /* If so, fake an error to force re-downloading */
     306        if (regExp.indexIn(strData) != -1)
     307            rc = VERR_HTTP_CACERT_WRONG_FORMAT;
     308
     309        /* Otherwise, check for two certificates: */
     310        if (RT_SUCCESS(rc))
     311        {
     312            regExp.setPattern(RENEW);
     313            regExp.setMinimal(true);
     314            if (regExp.indexIn(strData) == -1)
     315                rc = VERR_FILE_IO_ERROR;
     316        }
    310317
    311318        /* Verify certificates: */
     
    320327            rc = verifyCertificatePca3(pHttp, certificate);
    321328        }
    322 #ifndef VBOX_OSE
    323         if (RT_SUCCESS(rc))
    324         {
    325             QByteArray certificate = regExp.cap(3).toAscii();
    326             rc = verifyCertificatePca3IntG3(pHttp, certificate);
    327         }
    328 #endif
     329#undef CERT
     330#undef REOLD
     331#undef RENEW
    329332    }
    330333
     
    351354    if (RT_SUCCESS(rc))
    352355        rc = downloadCertificatePca3(pHttp, file);
    353 #ifndef VBOX_OSE
    354     /* Write the intermediate certificate: */
    355     if (RT_SUCCESS(rc))
    356     {
    357         /* Unfortunately the "VeriSign Class 3 International Server CA - G3" certificate
    358          * cannot be downloaded directly so we include a static copy here. */
    359         extern const char *g_pcszIntermediateCert;
    360         rc = file.write(g_pcszIntermediateCert) != -1 ? VINF_SUCCESS : VERR_WRITE_ERROR;
    361     }
    362     /* Add 'new-line' character: */
    363     if (RT_SUCCESS(rc))
    364 # ifdef Q_WS_WIN
    365         rc = file.write("\r\n") != -1 ? VINF_SUCCESS : VERR_WRITE_ERROR;
    366 # else /* Q_WS_WIN */
    367         rc = file.write("\n") != -1 ? VINF_SUCCESS : VERR_WRITE_ERROR;
    368 # endif /* !Q_WS_WIN */
    369 #endif
    370356
    371357    /* Close certificates file: */
     
    472458    return verifyCertificate(pHttp, certificate, pca3sha1, pca3sha512);
    473459}
    474 
    475 #ifndef VBOX_OSE
    476 int UINetworkReplyPrivateThread::verifyCertificatePca3IntG3(RTHTTP pHttp, QByteArray &certificate)
    477 {
    478     /* PCA 3 secure hash algorithm 1: */
    479     const unsigned char baSha1PCA3Int[] =
    480     {
    481         0xb1, 0x8d, 0x9d, 0x19, 0x56, 0x69, 0xba, 0x0f, 0x78, 0x29,
    482         0x51, 0x75, 0x66, 0xc2, 0x5f, 0x42, 0x2a, 0x27, 0x71, 0x04
    483     };
    484     /* PCA 3 secure hash algorithm 512: */
    485     const unsigned char baSha512PCA3Int[] =
    486     {
    487         0x43, 0x5a, 0xca, 0x67, 0x0a, 0xe4, 0x17, 0xfc,
    488         0x2d, 0xcd, 0xe9, 0x6c, 0x40, 0xde, 0x66, 0xed,
    489         0x39, 0x63, 0xfb, 0xe4, 0xd5, 0x60, 0xb8, 0xcc,
    490         0x83, 0x37, 0xc8, 0x50, 0x03, 0x2d, 0xb9, 0x1f,
    491         0x58, 0x02, 0x92, 0xcd, 0x2f, 0x66, 0xe8, 0x7c,
    492         0x2a, 0x70, 0x52, 0xce, 0x6d, 0xeb, 0x4d, 0x52,
    493         0x8a, 0x2a, 0x32, 0xc1, 0x15, 0x26, 0x63, 0x0c,
    494         0xbb, 0xc1, 0x64, 0x76, 0x9d, 0x54, 0x09, 0x0f
    495     };
    496     QByteArray pca3intsha1 = QByteArray::fromRawData((const char *)baSha1PCA3Int, sizeof(baSha1PCA3Int));
    497     QByteArray pca3intsha512 = QByteArray::fromRawData((const char *)baSha512PCA3Int, sizeof(baSha512PCA3Int));
    498 
    499     return verifyCertificate(pHttp, certificate, pca3intsha1, pca3intsha512);
    500 }
    501 #endif
    502460
    503461/* static */
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