diff options
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/sslinfo.ui | 283 | ||||
-rw-r--r-- | src/sslinfodialog.cpp | 122 | ||||
-rw-r--r-- | src/sslinfodialog.h | 71 | ||||
-rw-r--r-- | src/sslinfodialog_p.h | 107 | ||||
-rw-r--r-- | src/urlbar/sslwidget.cpp | 40 | ||||
-rw-r--r-- | src/urlbar/sslwidget.h | 5 |
7 files changed, 520 insertions, 110 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10d5b92b..fd946168 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ SET( rekonq_KDEINIT_SRCS previewselectorbar.cpp protocolhandler.cpp sessionmanager.cpp + sslinfodialog.cpp tabpreviewpopup.cpp tabbar.cpp tabhighlighteffect.cpp @@ -99,6 +100,7 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS settings/settings_webkit.ui settings/settings_adblock.ui cleardata.ui + sslinfo.ui useragent/useragentsettings.ui ) diff --git a/src/sslinfo.ui b/src/sslinfo.ui new file mode 100644 index 00000000..97ca69d0 --- /dev/null +++ b/src/sslinfo.ui @@ -0,0 +1,283 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SslInfo</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>460</width> + <height>432</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><h2>Certificate Information</h2></string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"/> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string/> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_20"> + <property name="text"> + <string><h4>Issued To:</h4></string> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Common Name (CN):</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="subjectCN"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Organization (O):</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="subjectO"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Organizational Unit (OU):</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="subjectOU"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Serial Number:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="subjectSN"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <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="label_21"> + <property name="text"> + <string><h4>Issued By:</h4></string> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Common Name (CN):</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="issuerCN"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_12"> + <property name="text"> + <string>Organization (O):</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Organizational Unit (OU):</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="issuerOU"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="issuerO"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_2"> + <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="label_22"> + <property name="text"> + <string><h4>Validity Period:</h4></string> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="0" column="0"> + <widget class="QLabel" name="label_14"> + <property name="text"> + <string>Issued on:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="issuedOn"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_18"> + <property name="text"> + <string>Expires on:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="expiresOn"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_3"> + <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="label_23"> + <property name="text"> + <string><h4>FingerPrints:</h4></string> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QLabel" name="label_36"> + <property name="text"> + <string>SHA-256 FingerPrints:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="sha256"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_38"> + <property name="text"> + <string>SHA-1 FingerPrints:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="sha1"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/sslinfodialog.cpp b/src/sslinfodialog.cpp new file mode 100644 index 00000000..67fc753d --- /dev/null +++ b/src/sslinfodialog.cpp @@ -0,0 +1,122 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com> +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* ============================================================ */ + + +// Self Includes +#include "sslinfodialog.h" +#include "sslinfodialog.moc" + +#include <KFileDialog> + +#include <QtGui/QFrame> +#include <QtCore/QDate> +#include <QtCore/QFile> +#include <QtGui/QLabel> +#include <QtGui/QLayout> +#include <QtCore/Q_PID> +#include <QtNetwork/QSslCertificate> + +#include <QFormLayout> + +#include <kglobal.h> +#include <klocale.h> + + +SslInfoDialog::SslInfoDialog(const QString &host, const WebSslInfo &info, QWidget *parent) + : KDialog(parent) + , m_host(host) + , m_info(info) +{ + setCaption(i18n("Rekonq SSL Information")); + setAttribute(Qt::WA_DeleteOnClose); + + setMinimumWidth(300); + + setButtons(KDialog::User1 | KDialog::Close); + + setButtonGuiItem(User1, KGuiItem(i18n("Export"), "view-certificate-export") ); + connect(this, SIGNAL(user1Clicked()), this, SLOT(exportCert())); + + ui.setupUi(mainWidget()); + + // ------------------------------------------------ + QList<QSslCertificate> caList = m_info.certificateChain(); + + Q_FOREACH(const QSslCertificate &cert, caList) + { + ui.comboBox->addItem( cert.subjectInfo(QSslCertificate::CommonName) ); + } + connect(ui.comboBox, SIGNAL(activated(int)), this, SLOT(displayFromChain(int))); + + QSslCertificate subjectCert = caList.first(); + + showCertificateInfo(subjectCert); +} + + +void SslInfoDialog::showCertificateInfo(QSslCertificate subjectCert) +{ + ui.subjectCN->setText( subjectCert.subjectInfo(QSslCertificate::CommonName) ); + ui.subjectO->setText( subjectCert.subjectInfo(QSslCertificate::Organization) ); + ui.subjectOU->setText( subjectCert.subjectInfo(QSslCertificate::OrganizationalUnitName) ); + ui.subjectSN->setText( subjectCert.serialNumber().toHex() ); + + ui.issuerCN->setText( subjectCert.issuerInfo(QSslCertificate::CommonName) ); + ui.issuerO->setText( subjectCert.issuerInfo(QSslCertificate::Organization) ); + ui.issuerOU->setText( subjectCert.issuerInfo(QSslCertificate::OrganizationalUnitName) ); + + ui.issuedOn->setText( subjectCert.effectiveDate().date().toString(Qt::SystemLocaleShortDate) ); + ui.expiresOn->setText( subjectCert.expiryDate().date().toString(Qt::SystemLocaleShortDate) ); + ui.sha256->setText( subjectCert.digest(QCryptographicHash::Md5).toHex() ); + ui.sha1->setText( subjectCert.digest(QCryptographicHash::Sha1).toHex() ); + +} + + +void SslInfoDialog::displayFromChain(int i) +{ + QList<QSslCertificate> caList = m_info.certificateChain(); + QSslCertificate cert = caList.at(i); + showCertificateInfo(cert); +} + + +void SslInfoDialog::exportCert() +{ + QSslCertificate cert = m_info.certificateChain().at( ui.comboBox->currentIndex() ); + + QString name = cert.subjectInfo(QSslCertificate::CommonName) + QL1S(".pem"); + + QString certPath = KFileDialog::getSaveFileName(name, QString(), this); + + kDebug() << certPath; + + QFile file(certPath); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + QTextStream out(&file); + out << cert.toPem(); +} diff --git a/src/sslinfodialog.h b/src/sslinfodialog.h new file mode 100644 index 00000000..c9b4c106 --- /dev/null +++ b/src/sslinfodialog.h @@ -0,0 +1,71 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com> +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* ============================================================ */ + + +#ifndef SSL_INFO_DIALOG_H +#define SSL_INFO_DIALOG_H + +#include "rekonq_defines.h" + +#include "websslinfo.h" + +// Ui Includes +#include "ui_sslinfo.h" + +#include <KDE/KDialog> + +#include <QList> + +class QSslCertificate; +class QString; + +/** + * Rekonq SSL Information Dialog + * + * This class creates a dialog that can be used to display information about + * an SSL session. + * + */ +class SslInfoDialog : public KDialog +{ + Q_OBJECT + +public: + explicit SslInfoDialog(const QString &host, const WebSslInfo &info, QWidget *parent = 0); + +private Q_SLOTS: + void displayFromChain(int); + void exportCert(); + +private: + void showCertificateInfo(QSslCertificate); + + QString m_host; + WebSslInfo m_info; + + Ui::SslInfo ui; +}; + +#endif // SSL_INFO_DIALOG_H diff --git a/src/sslinfodialog_p.h b/src/sslinfodialog_p.h deleted file mode 100644 index 72f16791..00000000 --- a/src/sslinfodialog_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/* This file is part of the KDE project - * - * Copyright (C) 2000-2003 George Staikos <staikos@kde.org> - * Copyright (C) 2000 Malte Starostik <malte@kde.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -#ifndef SSLINFODIALOG_P_H -#define SSLINFODIALOG_P_H - -#include <kdemacros.h> - -#include <KDE/KDialog> -#include <ktcpsocket.h> - -// NOTE: We need a copy of this header file is needed here because it -// is never installed by default by KIO. - -/** - * KDE SSL Information Dialog - * - * This class creates a dialog that can be used to display information about - * an SSL session. - * - * There are NO GUARANTEES that KSslInfoDialog will remain binary compatible/ - * Contact staikos@kde.org for details if needed. - * - * @author George Staikos <staikos@kde.org> - * @see KSSL - * @short KDE SSL Information Dialog - */ -class KDE_EXPORT KSslInfoDialog : public KDialog -{ - Q_OBJECT - -public: - /** - * Construct a KSSL Information Dialog - * - * @param parent the parent widget - */ - explicit KSslInfoDialog(QWidget *parent = 0); - - /** - * Destroy this dialog - */ - virtual ~KSslInfoDialog(); - - /** - * Tell the dialog if the connection has portions that may not be - * secure (ie. a mixture of secure and insecure frames) - * - * @param isIt true if security is in question - */ - void setSecurityInQuestion(bool isIt); - - /** - * Set information to display about the SSL connection. - * - * @param certificateChain the certificate chain leading from the certificate - * authority to the peer. - * @param ip the ip of the remote host - * @param host the remote hostname - * @param sslProtocol the version of SSL in use (SSLv2, SSLv3, TLSv1) - * @param cipher the cipher in use - * @param usedBits the used bits of the key - * @param bits the key size of the cipher in use - * @param validationErrors errors validating the certificates, if any - */ - void setSslInfo(const QList<QSslCertificate> &certificateChain, - const QString &ip, const QString &host, - const QString &sslProtocol, const QString &cipher, - int usedBits, int bits, - const QList<QList<KSslError::Error> > &validationErrors); - - void setMainPartEncrypted(bool); - void setAuxiliaryPartsEncrypted(bool); - - static QList<QList<KSslError::Error> > errorsFromString(const QString &s); - -private Q_SLOTS: - void launchConfig(); - void displayFromChain(int); - -private: - void updateWhichPartsEncrypted(); - - class KSslInfoDialogPrivate; - KSslInfoDialogPrivate* const d; -}; - -#endif // SSLINFODIALOG_P_H diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp index 79194c6f..40532cb3 100644 --- a/src/urlbar/sslwidget.cpp +++ b/src/urlbar/sslwidget.cpp @@ -31,6 +31,7 @@ // Local includes #include "application.h" #include "historymanager.h" +#include "sslinfodialog.h" // KDE Includes @@ -43,6 +44,8 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) : QMenu(parent) + , m_url(url) + , m_info(info) { setAttribute(Qt::WA_DeleteOnClose); setMinimumWidth(400); @@ -54,8 +57,9 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) QLabel *label; + // ------------------------------------------------------------------------------------------------------------------ label = new QLabel(this); - label->setText( QL1S("<h4>") + url.host() + QL1S("</h4>") ); + label->setText( i18n("<h4>Identity</h4>") ); layout->addRow(label); if (firstCA.isNull()) @@ -81,7 +85,13 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) } label = new QLabel(this); - label->setText( QL1S("<hr /><h4>") + i18n("Issued to") + QL1S("</h4>") ); // ----------------------------------------------- // + label->setText("<a href=\"moresslinfos\">Certificate Information</a>"); + connect(label, SIGNAL(linkActivated(const QString &)), this, SLOT(showMoreSslInfos(const QString &))); + layout->addRow(label); + + // ------------------------------------------------------------------------------------------------------------------ + label = new QLabel(this); + label->setText( QL1S("<hr /><h4>Encryption</h4>") ); // ----------------------------------------------- // layout->addRow(label); label = new QLabel(this); @@ -145,7 +155,7 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent) // ------------------------------------------------------------------------------------------------------------------ label = new QLabel(this); - label->setText( QL1S("<hr /><h4>") + i18n("Site Information") + QL1S("</h4>") ); + label->setText( i18n("<hr /><h4>Site Information</h4>") ); layout->addRow(label); label = new QLabel(this); @@ -180,3 +190,27 @@ void SSLWidget::accept() close(); } + + +void SSLWidget::showMoreSslInfos(const QString &) +{ + // FIXME: show it every time??? + if (m_info.isValid()) + { + QPointer<SslInfoDialog> dlg = new SslInfoDialog(m_url.host(), m_info, this); +// dlg->setSslInfo(m_info.certificateChain(), +// m_info.peerAddress().toString(), +// m_host, +// m_info.protocol(), +// m_info.ciphers(), +// m_info.usedChiperBits(), +// m_info.supportedChiperBits() +// ); + + dlg->exec(); + delete dlg; + + return; + } + +} diff --git a/src/urlbar/sslwidget.h b/src/urlbar/sslwidget.h index 4e36d364..00478f59 100644 --- a/src/urlbar/sslwidget.h +++ b/src/urlbar/sslwidget.h @@ -46,7 +46,12 @@ public: void showAt(const QPoint &pos); private Q_SLOTS: + void showMoreSslInfos(const QString &); void accept(); + +private: + QUrl m_url; + WebSslInfo m_info; }; #endif // SSL_WIDGET_H |