summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sslinfo.ui69
-rw-r--r--src/sslinfodialog.cpp74
-rw-r--r--src/sslinfodialog.h6
-rw-r--r--src/urlbar/sslwidget.cpp34
4 files changed, 137 insertions, 46 deletions
diff --git a/src/sslinfo.ui b/src/sslinfo.ui
index e31216b0..84d3f4b2 100644
--- a/src/sslinfo.ui
+++ b/src/sslinfo.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>460</width>
- <height>432</height>
+ <width>427</width>
+ <height>481</height>
</rect>
</property>
<property name="windowTitle">
@@ -28,7 +28,51 @@
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox"/>
+ <spacer name="verticalSpacer_6">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Certificate Chain:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="comboBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item>
<widget class="QLabel" name="certInfoLabel">
@@ -38,6 +82,19 @@
</widget>
</item>
<item>
+ <spacer name="verticalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
@@ -118,7 +175,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>20</height>
</size>
</property>
</spacer>
@@ -184,7 +241,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>20</height>
</size>
</property>
</spacer>
@@ -236,7 +293,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>40</height>
+ <height>20</height>
</size>
</property>
</spacer>
diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp
index 376480af..dc55e95a 100644
--- a/src/sslinfodialog.cpp
+++ b/src/sslinfodialog.cpp
@@ -70,32 +70,22 @@ SslInfoDialog::SslInfoDialog(const QString &host, const WebSslInfo &info, QWidge
ui.comboBox->addItem( cert.subjectInfo(QSslCertificate::CommonName) );
}
connect(ui.comboBox, SIGNAL(activated(int)), this, SLOT(displayFromChain(int)));
-
- QSslCertificate subjectCert = caList.first();
-
- 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) );
- }
+
+ displayFromChain(0);
}
-void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert, const QString &certErrors)
+void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert, const QStringList &certErrors)
{
- ui.certInfoLabel->setText(certErrors);
+ QStringList sl = certErrors;
+ QString c = sl.takeFirst();
+ c += QL1S("<ul>");
+ Q_FOREACH(const QString &s, sl)
+ {
+ c += QL1S("<li>") + s + QL1S("</li>");
+ }
+ c += QL1S("</ul>");
+ ui.certInfoLabel->setText(c);
ui.subjectCN->setText( subjectCert.subjectInfo(QSslCertificate::CommonName) );
ui.subjectO->setText( subjectCert.subjectInfo(QSslCertificate::Organization) );
@@ -118,7 +108,19 @@ void SslInfoDialog::displayFromChain(int i)
{
QList<QSslCertificate> caList = m_info.certificateChain();
QSslCertificate cert = caList.at(i);
- showCertificateInfo(cert, QString());
+
+ if (cert.isValid())
+ {
+ QStringList certInfo;
+ certInfo << i18n("The Certificate is Valid!");
+ showCertificateInfo(cert, certInfo );
+ }
+ else
+ {
+ QStringList errors = SslInfoDialog::errorsFromString(m_info.certificateErrors()).at(i);
+ errors.prepend( i18n("The certificate for this site is NOT valid for the following reasons:") );
+ showCertificateInfo(cert, errors );
+ }
}
@@ -139,3 +141,29 @@ void SslInfoDialog::exportCert()
QTextStream out(&file);
out << cert.toPem();
}
+
+
+// static -------------------------------------------------------------------------------------------
+QList<QStringList> SslInfoDialog::errorsFromString(const QString &s)
+{
+ QList<QStringList> resultList;
+
+ QStringList sl1 = s.split('\n', QString::KeepEmptyParts);
+
+ Q_FOREACH(const QString &certErrors, sl1)
+ {
+ QStringList errors;
+ QStringList sl = certErrors.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();
+ }
+ }
+ resultList << errors;
+ }
+ return resultList;
+}
diff --git a/src/sslinfodialog.h b/src/sslinfodialog.h
index bed5a8b7..c993e134 100644
--- a/src/sslinfodialog.h
+++ b/src/sslinfodialog.h
@@ -55,12 +55,14 @@ class SslInfoDialog : public KDialog
public:
explicit SslInfoDialog(const QString &host, const WebSslInfo &info, QWidget *parent = 0);
+ static QList<QStringList> errorsFromString(const QString &s);
+
private Q_SLOTS:
void displayFromChain(int);
void exportCert();
-
+
private:
- void showCertificateInfo(QSslCertificate, const QString &certErrors);
+ void showCertificateInfo(QSslCertificate, const QStringList &certErrors);
QString m_host;
WebSslInfo m_info;
diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp
index 8507aa61..b1819700 100644
--- a/src/urlbar/sslwidget.cpp
+++ b/src/urlbar/sslwidget.cpp
@@ -33,9 +33,6 @@
#include "historymanager.h"
#include "sslinfodialog.h"
-// KDE Includes
-#include <QSslError>
-
// Qt Includes
#include <QtGui/QDialogButtonBox>
#include <QtGui/QGridLayout>
@@ -90,22 +87,29 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)
}
else
{
- QString errors;
- QStringList sl = m_info.certificateErrors().split("\t", QString::SkipEmptyParts);
- Q_FOREACH(const QString &s, sl)
+ label = new QLabel(this);
+ label->setWordWrap(true);
+
+ QList<QStringList> errorList = SslInfoDialog::errorsFromString(m_info.certificateErrors());
+ if (errorList.at(0).isEmpty())
+ {
+ label->setText( i18n("The certificate for this site is valid, but some on the certificate chain are not!") );
+ imageLabel->setPixmap(KIcon("security-medium").pixmap(32));
+ }
+ else
{
- bool didConvert;
- QSslError::SslError error = static_cast<QSslError::SslError>(s.trimmed().toInt(&didConvert));
- if (didConvert)
+ QStringList sl = errorList.at(0);
+ QString c = QL1S("<ul>");
+ Q_FOREACH(const QString &s, sl)
{
- errors += QSslError(error).errorString() + QL1S("\n");
+ c += QL1S("<li>") + s + QL1S("</li>");
}
+ c += QL1S("</ul>");
+
+ label->setText( i18n("The certificate for this site is NOT valid, for the following reasons:\n%1", c) );
+ label->setTextFormat(Qt::RichText);
+ imageLabel->setPixmap(KIcon("security-low").pixmap(32));
}
- label = new QLabel(this);
- label->setWordWrap(true);
- 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));
}
}