diff options
| author | Andrea Diamantini <adjam7@gmail.com> | 2011-07-11 10:06:41 +0200 | 
|---|---|---|
| committer | Andrea Diamantini <adjam7@gmail.com> | 2011-07-18 11:37:08 +0200 | 
| commit | c36f3b1351088b86845dd8981a7a9b13b971606e (patch) | |
| tree | a039935a831f91fccf6e56ffb6e98e08bf27a513 | |
| parent | WARNING: HISTORY_VERSION upgrade!! (diff) | |
| download | rekonq-c36f3b1351088b86845dd8981a7a9b13b971606e.tar.xz | |
SSL rewamp, one step to finish!
These are last changes to clean up and improve SSL rekonq
communications.
It is yet missing a proper SSL errors API integration. You just need
to wait for the next commit...
| -rw-r--r-- | src/sslinfo.ui | 9 | ||||
| -rw-r--r-- | src/sslinfodialog.cpp | 25 | ||||
| -rw-r--r-- | src/sslinfodialog.h | 2 | ||||
| -rw-r--r-- | src/urlbar/sslwidget.cpp | 111 | ||||
| -rw-r--r-- | src/urlbar/urlbar.cpp | 5 | ||||
| -rw-r--r-- | src/webpage.cpp | 12 | ||||
| -rw-r--r-- | src/webpage.h | 5 | 
7 files changed, 130 insertions, 39 deletions
| diff --git a/src/sslinfo.ui b/src/sslinfo.ui index 97ca69d0..e31216b0 100644 --- a/src/sslinfo.ui +++ b/src/sslinfo.ui @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="UTF-8"?>  <ui version="4.0">   <class>SslInfo</class> - <widget class="QWidget" name="Form"> + <widget class="QWidget" name="SslInfo">    <property name="geometry">     <rect>      <x>0</x> @@ -31,6 +31,13 @@      <widget class="QComboBox" name="comboBox"/>     </item>     <item> +    <widget class="QLabel" name="certInfoLabel"> +     <property name="text"> +      <string>TextLabel</string> +     </property> +    </widget> +   </item> +   <item>      <widget class="QGroupBox" name="groupBox">       <property name="title">        <string/> diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp index cb60cef8..376480af 100644 --- a/src/sslinfodialog.cpp +++ b/src/sslinfodialog.cpp @@ -37,6 +37,7 @@  #include <QtGui/QLayout>  #include <QtCore/Q_PID>  #include <QtNetwork/QSslCertificate> +#include <QtNetwork/QSslError>  #include <QFormLayout> @@ -72,12 +73,30 @@ SslInfoDialog::SslInfoDialog(const QString &host, const WebSslInfo &info, QWidge      QSslCertificate subjectCert = caList.first(); -    showCertificateInfo(subjectCert); +    if (subjectCert.isValid()) +        showCertificateInfo(subjectCert, i18n("The Certificate is Valid!") ); +    else +    { +        QString errors; +        QStringList sl = info.certificateErrors().split("\t", QString::SkipEmptyParts); +        Q_FOREACH(const QString &s, sl) +        { +            bool didConvert; +            QSslError::SslError error = static_cast<QSslError::SslError>(s.trimmed().toInt(&didConvert)); +            if (didConvert)  +            { +                errors += QSslError(error).errorString() + QL1S("\n"); +            } +        } +        showCertificateInfo(subjectCert, i18n("The certificate for this site is NOT valid for the following reasons:\n%1", errors) ); +    }  } -void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert) +void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert, const QString &certErrors)  { +    ui.certInfoLabel->setText(certErrors); +          ui.subjectCN->setText( subjectCert.subjectInfo(QSslCertificate::CommonName) );      ui.subjectO->setText( subjectCert.subjectInfo(QSslCertificate::Organization) );      ui.subjectOU->setText( subjectCert.subjectInfo(QSslCertificate::OrganizationalUnitName) ); @@ -99,7 +118,7 @@ void SslInfoDialog::displayFromChain(int i)  {      QList<QSslCertificate> caList = m_info.certificateChain();      QSslCertificate cert = caList.at(i); -    showCertificateInfo(cert); +    showCertificateInfo(cert, QString());  } diff --git a/src/sslinfodialog.h b/src/sslinfodialog.h index c9b4c106..bed5a8b7 100644 --- a/src/sslinfodialog.h +++ b/src/sslinfodialog.h @@ -60,7 +60,7 @@ private Q_SLOTS:      void exportCert();  private: -    void showCertificateInfo(QSslCertificate); +    void showCertificateInfo(QSslCertificate, const QString &certErrors);      QString m_host;      WebSslInfo m_info; diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp index 862bdb3f..8507aa61 100644 --- a/src/urlbar/sslwidget.cpp +++ b/src/urlbar/sslwidget.cpp @@ -34,10 +34,11 @@  #include "sslinfodialog.h"  // KDE Includes +#include <QSslError>  // Qt Includes  #include <QtGui/QDialogButtonBox> -#include <QtGui/QFormLayout> +#include <QtGui/QGridLayout>  #include <QtGui/QLabel>  #include <QtGui/QPushButton> @@ -52,22 +53,28 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)      QSslCertificate cert = info.certificateChain().first(); -    QFormLayout *layout = new QFormLayout(this); +    QGridLayout *layout = new QGridLayout(this);      QLabel *label; -     +    QLabel *imageLabel; + +    int rows = 0;      // ------------------------------------------------------------------------------------------------------------------ +    imageLabel = new QLabel(this); +    layout->addWidget(imageLabel, rows , 0, Qt::AlignCenter); +      label = new QLabel(this);      label->setWordWrap(true);      label->setText( i18n("<h4>Identity</h4>") ); -    layout->addRow(label); - +    layout->addWidget(label, rows++, 1); +          if (cert.isNull())      {          label = new QLabel(this);          label->setWordWrap(true); -        label->setText( i18n("Warning: this site is carrying a NULL certificate") ); -        layout->addRow(label); +        label->setText( i18n("Warning: this site is carrying a NULL certificate!") ); +         +        imageLabel->setPixmap(KIcon("security-low").pixmap(32));      }      else      { @@ -75,50 +82,92 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)          {              label = new QLabel(this);              label->setWordWrap(true); -            label->setText( i18n("This certificate for this site is Valid and has been verified by ")  -                            + cert.issuerInfo(QSslCertificate::CommonName) ); -            layout->addRow(label); +            label->setText( i18n("This certificate for this site is valid and has been verified by:\n%1.",  +                                 cert.issuerInfo(QSslCertificate::CommonName)) ); +             +             +            imageLabel->setPixmap(KIcon("security-high").pixmap(32));          }          else          { +            QString errors; +            QStringList sl = m_info.certificateErrors().split("\t", QString::SkipEmptyParts); +            Q_FOREACH(const QString &s, sl) +            { +                bool didConvert; +                QSslError::SslError error = static_cast<QSslError::SslError>(s.trimmed().toInt(&didConvert)); +                if (didConvert)  +                { +                    errors += QSslError(error).errorString() + QL1S("\n"); +                } +            }              label = new QLabel(this);              label->setWordWrap(true); -            label->setText( i18n("Warning: The certificate for this site is NOT valid!") ); -            layout->addRow(label); +            label->setText( i18n("The certificate for this site is NOT valid for the following reasons:\n%1", errors) ); +             +            imageLabel->setPixmap(KIcon("security-medium").pixmap(32));          }      } -     + +    layout->addWidget(label, rows++, 1); +      label = new QLabel(this);      label->setWordWrap(true);      label->setText("<a href=\"moresslinfos\">Certificate Information</a>");      connect(label, SIGNAL(linkActivated(const QString &)), this, SLOT(showMoreSslInfos(const QString &))); -    layout->addRow(label); +    layout->addWidget(label, rows++, 1);      // ------------------------------------------------------------------------------------------------------------------      label = new QLabel(this);      label->setWordWrap(true); -    label->setText( QL1S("<hr /><h4>Encryption</h4>") ); // ----------------------------------------------- // -    layout->addRow(label); +    label->setText( QL1S("<h4>Encryption</h4>") ); // ----------------------------------------------- // +    layout->addWidget(label, rows, 1); + +    imageLabel = new QLabel(this); +    layout->addWidget(imageLabel, rows++ , 0, Qt::AlignCenter);      if (cert.isNull())      {          label = new QLabel(this);          label->setWordWrap(true);          label->setText( i18n("Your connection to %1 is NOT encrypted!!\n\n", m_url.host()) ); -        layout->addRow(label);         +        layout->addWidget(label, rows++ , 1); +         +        imageLabel->setPixmap(KIcon("security-low").pixmap(32));      }      else      {          label = new QLabel(this);          label->setWordWrap(true); -        label->setText( i18n("Your connection to %1 is encrypted with %2 encryption\n\n", m_url.host(), m_info.supportedChiperBits()) ); -        layout->addRow(label); +        label->setText( i18n("Your connection to %1 is encrypted with %2-bit encryption.\n\n", m_url.host(), m_info.supportedChiperBits()) ); +        layout->addWidget(label, rows++, 1); -        QString sslVersion = QL1S("SSLv") + cert.version(); +        int vers = cert.version().toInt(); +        QString sslVersion; +        switch(vers) +        { +        case 0: +            sslVersion = QL1S("SSL 3.0"); +            imageLabel->setPixmap(KIcon("security-high").pixmap(32)); +            break; +        case 1: +            sslVersion = QL1S("SSL 2.0"); +            imageLabel->setPixmap(KIcon("security-medium").pixmap(32)); +            break; +        case 2: +        case 3: +            sslVersion = QL1S("TLS 1.0"); +            imageLabel->setPixmap(KIcon("security-high").pixmap(32)); +            break; +        default: +            sslVersion = QL1S("Unknown"); +            imageLabel->setPixmap(KIcon("security-medium").pixmap(32)); +        } +          label = new QLabel(this);          label->setWordWrap(true); -        label->setText( i18n("The connection uses %1\n\n", sslVersion) ); -        layout->addRow(label); +        label->setText( i18n("The connection uses %1.\n\n", sslVersion) ); +        layout->addWidget(label, rows++, 1);          const QStringList cipherInfo = m_info.ciphers().split('\n', QString::SkipEmptyParts);          label = new QLabel(this); @@ -129,14 +178,18 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)              m_info.usedChiperBits(),              cipherInfo[3],              cipherInfo[1]) ); -        layout->addRow(label); +        layout->addWidget(label, rows++, 1); +              }      // ------------------------------------------------------------------------------------------------------------------ +    imageLabel = new QLabel(this); +    layout->addWidget(imageLabel, rows , 0, Qt::AlignCenter); +      label = new QLabel(this);      label->setWordWrap(true); -    label->setText( i18n("<hr /><h4>Site Information</h4>") ); -    layout->addRow(label); +    label->setText( i18n("<h4>Site Information</h4>") ); +    layout->addWidget(label, rows++, 1);      label = new QLabel(this);      label->setWordWrap(true); @@ -145,13 +198,15 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)      if (firstVisit.visitCount == 1)      { -        label->setText( i18n("It's your first time visiting this site") );             +        label->setText( i18n("It's your first time visiting this site!") );             +        imageLabel->setPixmap(KIcon("security-medium").pixmap(32));      }      else      { -        label->setText( i18n("You just visited this site!\nYour first visit was on %1", firstVisit.firstDateTimeVisit.toString()) ); +        label->setText( i18n("You just visited this site!\nYour first visit was on %1.\n", firstVisit.firstDateTimeVisit.toString()) ); +        imageLabel->setPixmap(KIcon("security-high").pixmap(32));      } -    layout->addRow(label); +    layout->addWidget(label, rows++, 1);      // -----------------------------------------------------------------------------------      setLayout(layout); diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index fa23b6c6..8b3dac65 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -356,6 +356,7 @@ void UrlBar::loadFinished()      // show SSL      if(_tab->url().scheme() == QL1S("https"))      { +        // NOTE: the choice for the right SSL icon is done in the addRightIcon method          IconButton *bt = addRightIcon(UrlBar::SSL);          connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo(QPoint)));      } @@ -465,8 +466,8 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)          break;      case UrlBar::SSL:          _tab->page()->hasSslValid() -            ? rightIcon->setIcon(KIcon("security-high")) -            : rightIcon->setIcon(KIcon("security-low")); +            ? rightIcon->setIcon(KIcon("object-locked")) +            : rightIcon->setIcon(KIcon("object-unlocked"));          rightIcon->setToolTip(i18n("Show SSL Info"));          break;      case UrlBar::BK: diff --git a/src/webpage.cpp b/src/webpage.cpp index 9185a25b..95d7b6ae 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -763,3 +763,15 @@ void WebPage::copyToTempFileResult(KJob* job)      else          (void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), _mimeType, rApp->mainWindow());  } + + +bool WebPage::hasSslValid() +{ +    bool v = true; +    QList<QSslCertificate> certList = _sslInfo.certificateChain(); +    Q_FOREACH(const QSslCertificate &cert, certList) +    { +        v &= cert.isValid(); +    } +    return v; +} diff --git a/src/webpage.h b/src/webpage.h index 86355395..cc407016 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -80,10 +80,7 @@ public:          return _suggestedFileName;      }; -    inline bool hasSslValid() -    { -        return _sslInfo.isValid(); -    } +    bool hasSslValid();  public Q_SLOTS:      void downloadAllContentsWithKGet(QPoint); | 
