Changeset 371:4077a660b294 in SMSSender


Ignore:
Timestamp:
Apr 14, 2014 11:38:40 AM (4 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Even more information is printed out when encountering an ssl error in SNetworkHelper.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/network/snetworkhelper.cpp

    r364 r371  
    5959
    6060        connect(nam, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
    61                 this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
     61                this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)),
     62                Qt::DirectConnection);
    6263    }
    6364    return *networkAccessManager_.value(QThread::currentThread());
     
    371372
    372373
     374QString certToString(const QSslCertificate &cert, const QString &delim) {
     375    QString subjectOrganization = cert.subjectInfo(QSslCertificate::Organization);
     376    QString subjectCommonName = cert.subjectInfo(QSslCertificate::CommonName);
     377    QString subjectLocalityName = cert.subjectInfo(QSslCertificate::LocalityName);
     378    QString subjectOrganizationalUnitName = cert.subjectInfo(QSslCertificate::OrganizationalUnitName);
     379
     380    QString issuerOrganization = cert.issuerInfo(QSslCertificate::Organization);
     381    QString issuerCommonName = cert.issuerInfo(QSslCertificate::CommonName);
     382    QString issuerLocalityName = cert.issuerInfo(QSslCertificate::LocalityName);
     383    QString issuerOrganizationalUnitName = cert.issuerInfo(QSslCertificate::OrganizationalUnitName);
     384
     385    return QString("s:[%1]%2i:[%3]")
     386            .arg(QString("O=%1,CN=%2,L=%3,OU=%4,S=%5")
     387                 .arg(subjectOrganization)
     388                 .arg(subjectCommonName)
     389                 .arg(subjectLocalityName)
     390                 .arg(subjectOrganizationalUnitName)
     391                 .arg(QString(cert.serialNumber())))
     392            .arg(delim)
     393            .arg(QString("O=%1,CN=%2,L=%3,OU=%4")
     394                 .arg(issuerOrganization)
     395                 .arg(issuerCommonName)
     396                 .arg(issuerLocalityName)
     397                 .arg(issuerOrganizationalUnitName));
     398}
     399
    373400void SNetworkHelper::onSslErrors(QNetworkReply* reply, const QList<QSslError>& errors) {
    374     Q_UNUSED(reply);
    375 
    376     qDebug() << "SSL-Errors occured:";
     401    qDebug() << QString("SSL errors occured while connecting to %1:")
     402                .arg(reply->request().url().toString());
     403
    377404    foreach (QSslError error, errors) {
    378         QString subjectOrganization = error.certificate().subjectInfo(QSslCertificate::Organization);
    379         QString subjectOrganizationalUnitName = error.certificate().subjectInfo(QSslCertificate::OrganizationalUnitName);
    380         QString issuerOrganization = error.certificate().issuerInfo(QSslCertificate::Organization);
    381         QString issuerOrganizationalUnitName = error.certificate().issuerInfo(QSslCertificate::OrganizationalUnitName);
    382 
    383         qDebug() << QString("s:[O=%1,OU=%2],i:[O=%3,OU=%4],serial:%5: %6")
    384                     .arg(subjectOrganization)
    385                     .arg(subjectOrganizationalUnitName)
    386                     .arg(issuerOrganization)
    387                     .arg(issuerOrganizationalUnitName)
    388                     .arg(QString(error.certificate().serialNumber()))
    389                     .arg(error.errorString());
     405        qDebug() << QString("%1\n  %2")
     406                    .arg(error.errorString())
     407                    .arg(certToString(error.certificate(), "\n  "));
     408    }
     409
     410    qDebug() << "Installed CAs:";
     411    unsigned i = 0;
     412    foreach (const QSslCertificate &cert, reply->request().sslConfiguration().caCertificates()) {
     413        qDebug() << QString("%1: %2")
     414                    .arg(i)
     415                    .arg(certToString(cert, "\n   "));
     416        ++i;
    390417    }
    391418}
Note: See TracChangeset for help on using the changeset viewer.