1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Added new SSL Manager, it is now possible to specify location for custom

CA Certificates
This commit is contained in:
nowrep 2011-10-12 22:28:41 +02:00
parent 58a029fcc1
commit 2ff570e92c
15 changed files with 646 additions and 159 deletions

BIN
bin/locale/qt_nl.qm Normal file

Binary file not shown.

View File

@ -233,7 +233,6 @@ QColor QtWin::colorizationColor()
}
#ifdef Q_WS_WIN
#ifdef W7API
WindowNotifier *QtWin::windowNotifier()
{
static WindowNotifier *windowNotifierInstance = 0;
@ -258,6 +257,7 @@ bool WindowNotifier::winEvent(MSG *message, long *result)
return QWidget::winEvent(message, result);
}
#ifdef W7API
IShellLink* QtWin::CreateShellLink(const QString &title, const QString &description,
const QString &app_path, const QString &app_args,
const QString &icon_path, int app_index) {
@ -351,8 +351,8 @@ void QtWin::AddTasksToList(ICustomDestinationList* destinationList) {
object_array->Release();
obj_collection->Release();
}
#endif //Q_WS_WIN
#endif //W7API
#endif //Q_WS_WIN
void QtWin::setupJumpList() {
#ifdef W7API

View File

@ -165,7 +165,7 @@ MainApplication::MainApplication(const QList<CommandLineOptions::ActionPair> &cm
settings2.setValue("Plugin-Settings/EnablePlugins", false);
}
networkManager()->loadCertExceptions();
networkManager()->loadCertificates();
plugins()->loadPlugins();
loadSettings();
@ -403,7 +403,7 @@ void MainApplication::quitApplication()
m_historymodel->clearHistory();
cookieJar()->saveCookies();
m_networkmanager->saveCertExceptions();
m_networkmanager->saveCertificates();
m_plugins->c2f_saveSettings();
AdBlockManager::instance()->save();
QFile::remove(getActiveProfilPath() + "WebpageIcons.db");

View File

@ -69,7 +69,7 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QS
connect(manager, SIGNAL(resized(QSize)), this, SLOT(parentResized(QSize)));
m_downloading = true;
m_timer.start(1000*1, this);
m_timer.start(1000, this);
readyRead();
QTimer::singleShot(500, this, SLOT(updateDownload()));
@ -281,13 +281,7 @@ void DownloadItem::customContextMenuRequested(const QPoint &pos)
menu.addAction(tr("Go to Download Page"), this, SLOT(goToDownloadPage()))->setEnabled(!m_downloadPage.isEmpty());
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Download Link"), this, SLOT(copyDownloadLink()));
menu.addSeparator();
menu.addAction(
#ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_BrowserStop)
#else
QIcon(":/icons/faenza/stop.png")
#endif
,tr("Cancel downloading"), this, SLOT(stop()))->setEnabled(m_downloading);
menu.addAction(IconProvider::standardIcon(QStyle::SP_BrowserStop), tr("Cancel downloading"), this, SLOT(stop()))->setEnabled(m_downloading);
menu.addAction(QIcon::fromTheme("window-close"), tr("Clear"), this, SLOT(clear()))->setEnabled(!m_downloading);
if (m_downloading || ui->downloadInfo->text().startsWith(tr("Cancelled")) || ui->downloadInfo->text().startsWith(tr("Error")))

View File

@ -26,6 +26,8 @@
#include "adblocknetwork.h"
#include "networkproxyfactory.h"
#include "qupzillaschemehandler.h"
#include "certificateinfowidget.h"
#include "globalfunctions.h"
NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
: NetworkManagerProxy(mainClass, parent)
@ -55,7 +57,6 @@ void NetworkManager::loadSettings()
m_diskCache->setMaximumCacheSize(settings.value("MaximumCacheSize",50).toInt() * 1024*1024); //MegaBytes
setCache(m_diskCache);
}
m_ignoreAllWarnings = settings.value("IgnoreAllSSLWarnings", false).toBool();
m_doNotTrack = settings.value("DoNotTrack", false).toBool();
settings.endGroup();
@ -105,14 +106,14 @@ void NetworkManager::sslError(QNetworkReply* reply, QList<QSslError> errors)
QStringList actions;
foreach (QSslError error, errors) {
if (m_certExceptions.contains(error.certificate()))
if (m_localCerts.contains(error.certificate()))
continue;
if (error.error() == QSslError::NoError) //Weird behavior on Windows
continue;
QSslCertificate cert = error.certificate();
actions.append(tr("<b>Organization: </b>") + cert.subjectInfo(QSslCertificate::Organization));
actions.append(tr("<b>Domain Name: </b>") + cert.subjectInfo(QSslCertificate::CommonName));
actions.append(tr("<b>Organization: </b>") + CertificateInfoWidget::clearCertSpecialSymbols(cert.subjectInfo(QSslCertificate::Organization)));
actions.append(tr("<b>Domain Name: </b>") + CertificateInfoWidget::clearCertSpecialSymbols(cert.subjectInfo(QSslCertificate::CommonName)));
actions.append(tr("<b>Expiration Date: </b>") + cert.expiryDate().toString("hh:mm:ss dddd d. MMMM yyyy"));
actions.append(tr("<b>Error: </b>") + error.errorString());
}
@ -130,9 +131,9 @@ void NetworkManager::sslError(QNetworkReply* reply, QList<QSslError> errors)
}
foreach (QSslError error, errors) {
if (m_certExceptions.contains(error.certificate()))
if (m_localCerts.contains(error.certificate()))
continue;
m_certExceptions.append(error.certificate());
addLocalCertificate(error.certificate());
}
reply->ignoreSslErrors(errors);
@ -264,36 +265,102 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
return reply;
}
void NetworkManager::saveCertExceptions()
void NetworkManager::removeLocalCertificate(const QSslCertificate &cert)
{
QFile file(mApp->getActiveProfilPath()+"sslexceptions.dat");
file.open(QIODevice::WriteOnly);
QDataStream stream(&file);
m_localCerts.removeOne(cert);
QList<QSslCertificate> certs = QSslSocket::defaultCaCertificates();
certs.removeOne(cert);
QSslSocket::setDefaultCaCertificates(certs);
int count = m_certExceptions.count();
stream << count;
//Delete cert file from profile
QString certFileName = CertificateInfoWidget::certificateItemText(cert);
int startIndex = 0;
QDirIterator it(mApp->getActiveProfilPath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
while (it.hasNext()) {
QString filePath = startIndex == 0 ? it.next() : it.next().mid(startIndex);
if (!filePath.contains(certFileName))
continue;
for (int i = 0; i < count; i++) {
stream << m_certExceptions.at(i).toPem();
QFile file(filePath);
file.remove();
break;
}
}
void NetworkManager::addLocalCertificate(const QSslCertificate &cert)
{
if (!cert.isValid())
return;
m_localCerts.append(cert);
QSslSocket::addDefaultCaCertificate(cert);
QDir dir(mApp->getActiveProfilPath());
if (!dir.exists("certificates"))
dir.mkdir("certificates");
QString fileName = qz_ensureUniqueFilename(mApp->getActiveProfilPath() + "certificates/" + CertificateInfoWidget::certificateItemText(cert).remove(" ") + ".crt");
QFile file(fileName);
if (file.open(QFile::WriteOnly)) {
file.write(cert.toPem());
file.close();
}
}
void NetworkManager::loadCertExceptions()
void NetworkManager::saveCertificates()
{
QFile file(mApp->getActiveProfilPath()+"sslexceptions.dat");
file.open(QIODevice::ReadOnly);
QDataStream stream(&file);
int count;
stream >> count;
QByteArray cert;
for (int i = 0; i < count; i++) {
stream >> cert;
m_certExceptions.append(QSslCertificate::fromData(cert));
QSettings settings(mApp->getActiveProfilPath() + "settings.ini", QSettings::IniFormat);
settings.beginGroup("SSL-Configuration");
settings.setValue("CACertPaths", m_certPaths);
settings.setValue("IgnoreAllSSLWarnings", m_ignoreAllWarnings);
settings.endGroup();
}
file.close();
void NetworkManager::loadCertificates()
{
QSettings settings(mApp->getActiveProfilPath() + "settings.ini", QSettings::IniFormat);
settings.beginGroup("SSL-Configuration");
m_certPaths = settings.value("CACertPaths", QStringList()).toStringList();
m_ignoreAllWarnings = settings.value("IgnoreAllSSLWarnings", false).toBool();
settings.endGroup();
//CA Certificates
m_caCerts = QSslSocket::defaultCaCertificates();
foreach (QString path, m_certPaths) {
#ifdef Q_WS_WIN
// Used from Qt 4.7.4 qsslcertificate.cpp and modified because QSslCertificate::fromPath
// is kind of a bugged on Windows, it does work only with full path to cert file
int startIndex = 0;
QDirIterator it(path, QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
while (it.hasNext()) {
QString filePath = startIndex == 0 ? it.next() : it.next().mid(startIndex);
if (!filePath.endsWith(".crt"))
continue;
QFile file(filePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
m_caCerts += QSslCertificate::fromData(file.readAll(), QSsl::Pem);
}
#else
m_caCerts += QSslCertificate::fromPath(path + "/*.crt", QSsl::Pem, QRegExp::Wildcard);
#endif
}
//Local Certificates
#ifdef Q_WS_WIN
int startIndex = 0;
QDirIterator it_(mApp->getActiveProfilPath() + "certificates", QDir::Files, QDirIterator::FollowSymlinks | QDirIterator::Subdirectories);
while (it_.hasNext()) {
QString filePath = startIndex == 0 ? it_.next() : it_.next().mid(startIndex);
if (!filePath.endsWith(".crt"))
continue;
QFile file(filePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
m_localCerts += QSslCertificate::fromData(file.readAll(), QSsl::Pem);
}
#else
m_localCerts += QSslCertificate::fromPath(mApp->getActiveProfilPath() + "certificates/*.crt", QSsl::Pem, QRegExp::Wildcard);
#endif
QSslSocket::setDefaultCaCertificates(m_caCerts + m_localCerts);
}

View File

@ -28,6 +28,8 @@
#include <QCheckBox>
#include <QSslError>
#include <QNetworkDiskCache>
#include <QSslSocket>
#include <QSslConfiguration>
#include "networkmanagerproxy.h"
@ -42,10 +44,21 @@ public:
explicit NetworkManager(QupZilla* mainClass, QObject* parent = 0);
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData);
QList<QSslCertificate> getCertExceptions() { return m_certExceptions; }
void setCertExceptions(QList<QSslCertificate> certs) { m_certExceptions = certs; }
void saveCertExceptions();
void loadCertExceptions();
void saveCertificates();
void loadCertificates();
QList<QSslCertificate> getCaCertificates() { return m_caCerts; }
QList<QSslCertificate> getLocalCertificates() { return m_localCerts; }
void removeLocalCertificate(const QSslCertificate &cert);
void addLocalCertificate(const QSslCertificate &cert);
void setCertificatePaths(const QStringList &paths) { m_certPaths = paths; }
QStringList certificatePaths() { return m_certPaths; }
void setIgnoreAllWarnings(bool state) { m_ignoreAllWarnings = state; }
bool isIgnoringAllWarnings() { return m_ignoreAllWarnings; }
void loadSettings();
signals:
@ -62,12 +75,14 @@ private slots:
private:
AdBlockNetwork* m_adblockNetwork;
QupZilla* p_QupZilla;
QList<QSslCertificate> m_certExceptions;
QNetworkDiskCache* m_diskCache;
NetworkProxyFactory* m_proxyFactory;
QupZillaSchemeHandler* m_qupzillaSchemeHandler;
QStringList m_certPaths;
QList<QSslCertificate> m_caCerts;
QList<QSslCertificate> m_localCerts;
bool m_ignoreAllWarnings;
bool m_doNotTrack;
};

View File

@ -70,8 +70,9 @@ void AboutDialog::showAuthors()
if (m_authorsHtml.isEmpty()) {
m_authorsHtml.append("<div style='margin:10px;'>");
m_authorsHtml.append(tr("<p><b>Main developers:</b><br/>%1 &lt;%2&gt;</p>").arg(QupZilla::AUTHOR, "<a href=mailto:nowrep@gmail.com>nowrep@gmail.com</a>"));
m_authorsHtml.append(tr("<p><b>Other contributors:</b><br/>%1</p>").arg("Rajny :: Graphics <br/> Mikino :: Slovakia Translation"));
m_authorsHtml.append(tr("<p><b>Thanks to:</b><br/>%1</p>").arg("Patrick :: First User"));
m_authorsHtml.append(tr("<p><b>Other contributors:</b><br/>%1</p>").arg("Heimen Stoffels - Dutch Translation<br/>"
"Peter Vacula - Slovakia Translation"));
m_authorsHtml.append(tr("<p><b>Thanks to:</b><br/>%1</p>").arg("Patrick for support in the beginning"));
m_authorsHtml.append("</div>");
}
ui->textBrowser->setHtml(m_authorsHtml);

View File

@ -19,86 +19,157 @@
#include "ui_sslmanager.h"
#include "networkmanager.h"
#include "mainapplication.h"
#include "globalfunctions.h"
#include "certificateinfowidget.h"
SSLManager::SSLManager(QWidget* parent) :
QWidget(parent),
ui(new Ui::SSLManager)
SSLManager::SSLManager(QWidget* parent)
: QWidget(parent)
, ui(new Ui::SSLManager)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
qz_centerWidgetOnScreen(this);
refresh();
refreshLocalList();
refreshCAList();
refreshPaths();
connect(ui->list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showCertificateInfo()));
connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showCertificateInfo()));
connect(ui->caList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showCaCertInfo()));
connect(ui->caInfoButton, SIGNAL(clicked()), this, SLOT(showCaCertInfo()));
connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCertificate()));
connect(ui->localList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showLocalCertInfo()));
connect(ui->localInfoButton, SIGNAL(clicked()), this, SLOT(showLocalCertInfo()));
connect(ui->addPath, SIGNAL(clicked()), this, SLOT(addPath()));
connect(ui->deletePath, SIGNAL(clicked()), this, SLOT(deletePath()));
connect(ui->ignoreAll, SIGNAL(clicked(bool)), this, SLOT(ignoreAll(bool)));
QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat);
settings.beginGroup("Web-Browser-Settings");
ui->ignoreAll->setChecked( settings.value("IgnoreAllSSLWarnings", false).toBool() );
settings.endGroup();
ui->ignoreAll->setChecked(mApp->networkManager()->isIgnoringAllWarnings());
}
void SSLManager::refresh()
void SSLManager::addPath()
{
ui->list->setUpdatesEnabled(false);
ui->list->clear();
m_certs = mApp->networkManager()->getCertExceptions();
foreach (QSslCertificate cert, m_certs) {
QListWidgetItem* item = new QListWidgetItem(ui->list);
item->setText( cert.subjectInfo(QSslCertificate::Organization) + " " + cert.subjectInfo(QSslCertificate::CommonName) );
item->setWhatsThis(QString::number(m_certs.indexOf(cert)));
ui->list->addItem(item);
}
ui->list->setCurrentRow(0);
ui->list->setUpdatesEnabled(true);
QString path = QFileDialog::getExistingDirectory(this, tr("Choose path..."));
if (path.isEmpty())
return;
ui->pathList->addItem(path);
}
void SSLManager::showCertificateInfo()
void SSLManager::deletePath()
{
QListWidgetItem* item = ui->list->currentItem();
QListWidgetItem* currentItem = ui->pathList->currentItem();
if (!currentItem)
return;
delete currentItem;
}
void SSLManager::refreshCAList()
{
ui->caList->setUpdatesEnabled(false);
ui->caList->clear();
m_caCerts = QSslSocket::defaultCaCertificates();
foreach (QSslCertificate cert, m_caCerts) {
QListWidgetItem* item = new QListWidgetItem(ui->caList);
item->setText( CertificateInfoWidget::certificateItemText(cert) );
item->setWhatsThis(QString::number(m_caCerts.indexOf(cert)));
ui->caList->addItem(item);
}
ui->caList->setCurrentRow(0);
ui->caList->setUpdatesEnabled(true);
}
void SSLManager::refreshLocalList()
{
ui->localList->setUpdatesEnabled(false);
ui->localList->clear();
m_localCerts = mApp->networkManager()->getLocalCertificates();
foreach (QSslCertificate cert, m_localCerts) {
QListWidgetItem* item = new QListWidgetItem(ui->localList);
item->setText( CertificateInfoWidget::certificateItemText(cert) );
item->setWhatsThis(QString::number(m_localCerts.indexOf(cert)));
ui->localList->addItem(item);
}
ui->localList->setCurrentRow(0);
ui->localList->setUpdatesEnabled(true);
}
void SSLManager::refreshPaths()
{
foreach (QString path, mApp->networkManager()->certificatePaths())
ui->pathList->addItem(path);
}
void SSLManager::showCaCertInfo()
{
QListWidgetItem* item = ui->caList->currentItem();
if (!item)
return;
QSslCertificate cert = m_certs.at(item->whatsThis().toInt());
QStringList actions;
actions.append(tr("<b>Organization: </b>") + cert.subjectInfo(QSslCertificate::Organization));
actions.append(tr("<b>Domain Name: </b>") + cert.subjectInfo(QSslCertificate::CommonName));
actions.append(tr("<b>Locality Name: </b>") + cert.subjectInfo(QSslCertificate::LocalityName));
actions.append(tr("<b>Country Name: </b>") + cert.subjectInfo(QSslCertificate::CountryName));
actions.append(tr("<b>Verified by: </b>") + cert.subjectInfo(QSslCertificate::OrganizationalUnitName));
actions.append(tr("<b>Expiration Date: </b>") + cert.expiryDate().toString("hh:mm:ss dddd d. MMMM yyyy"));
QSslCertificate cert = m_caCerts.at(item->whatsThis().toInt());
showCertificateInfo(cert);
}
QString message = QString(QLatin1String("<ul><li>%3</li></ul>")).arg(actions.join(QLatin1String("</li><li>")));
void SSLManager::showLocalCertInfo()
{
QListWidgetItem* item = ui->localList->currentItem();
if (!item)
return;
QMessageBox mes;
mes.setIcon(QMessageBox::Information);
mes.setWindowTitle(tr("SSL Certificate Informations"));
mes.setText(message);
mes.setDetailedText(cert.toPem());
mes.exec();
QSslCertificate cert = m_localCerts.at(item->whatsThis().toInt());
showCertificateInfo(cert);
}
void SSLManager::showCertificateInfo(const QSslCertificate &cert)
{
QWidget* w = new QWidget();
w->setAttribute(Qt::WA_DeleteOnClose);
w->setWindowTitle(tr("Certificate Informations"));
w->setLayout(new QVBoxLayout);
CertificateInfoWidget* c = new CertificateInfoWidget(cert);
w->layout()->addWidget(c);
QDialogButtonBox* b = new QDialogButtonBox(w);
b->setStandardButtons(QDialogButtonBox::Close);
connect(b, SIGNAL(clicked(QAbstractButton*)), w, SLOT(close()));
w->layout()->addWidget(b);
w->resize(w->sizeHint());
qz_centerWidgetOnScreen(w);
w->show();
}
void SSLManager::deleteCertificate()
{
QListWidgetItem* item = ui->list->currentItem();
QListWidgetItem* item = ui->localList->currentItem();
if (!item)
return;
QSslCertificate cert = m_certs.at(item->whatsThis().toInt());
m_certs.removeOne(cert);
mApp->networkManager()->setCertExceptions(m_certs);
refresh();
QSslCertificate cert = m_localCerts.at(item->whatsThis().toInt());
m_localCerts.removeOne(cert);
mApp->networkManager()->removeLocalCertificate(cert);
refreshLocalList();
}
void SSLManager::ignoreAll(bool state)
{
QSettings settings(mApp->getActiveProfilPath()+"settings.ini", QSettings::IniFormat);
settings.beginGroup("Web-Browser-Settings");
settings.setValue("IgnoreAllSSLWarnings", state);
settings.endGroup();
mApp->networkManager()->loadSettings();
mApp->networkManager()->setIgnoreAllWarnings(state);
}
void SSLManager::closeEvent(QCloseEvent *e)
{
QStringList paths;
for (int i = 0; i < ui->pathList->count(); i++) {
QListWidgetItem* item = ui->pathList->item(i);
if (!item || item->text().isEmpty())
continue;
paths.append(item->text());
}
mApp->networkManager()->setCertificatePaths(paths);
QWidget::closeEvent(e);
}
SSLManager::~SSLManager()

View File

@ -24,6 +24,8 @@
#include <QSslCertificate>
#include <QDateTime>
#include <QSettings>
#include <QFileDialog>
#include <QCloseEvent>
namespace Ui {
class SSLManager;
@ -38,14 +40,27 @@ public:
~SSLManager();
private slots:
void showCertificateInfo();
void showLocalCertInfo();
void showCaCertInfo();
void deleteCertificate();
void ignoreAll(bool state);
void addPath();
void deletePath();
private:
void refresh();
void closeEvent(QCloseEvent *e);
void refreshLocalList();
void refreshCAList();
void refreshPaths();
void showCertificateInfo(const QSslCertificate &cert);
Ui::SSLManager* ui;
QList<QSslCertificate> m_certs;
QList<QSslCertificate> m_localCerts;
QList<QSslCertificate> m_caCerts;
};
#endif // SSLMANAGER_H

View File

@ -6,16 +6,70 @@
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>250</height>
<width>653</width>
<height>389</height>
</rect>
</property>
<property name="windowTitle">
<string>SSL Manager</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>CA Authorities Certificates</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QListWidget" name="list"/>
<widget class="QListWidget" name="caList"/>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<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="QPushButton" name="caInfoButton">
<property name="text">
<string>Show info</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>This is list of CA Authorities Certificates stored in standard system path and in user specified paths.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Local Certificates</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QListWidget" name="localList"/>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
@ -33,7 +87,7 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="infoButton">
<widget class="QPushButton" name="localInfoButton">
<property name="text">
<string>Show info</string>
</property>
@ -49,13 +103,134 @@
</layout>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>This is list of Local Certificates stored in user profile. This list also contains all certificates, that have received an exception.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="4" column="0">
<widget class="QListWidget" name="pathList"/>
</item>
<item row="4" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<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="QPushButton" name="addPath">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deletePath">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_3">
<property name="text">
<string>If CA Authorities Certificates were not automatically loaded from system, You can specify manual paths where certificates are stored.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;b&gt;NOTE:&lt;/b&gt; Setting this option is big security vulnerability!</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="ignoreAll">
<property name="text">
<string>Ignore all warnings</string>
<string>Ignore all SSL Warnings</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<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>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>

View File

@ -1,11 +1,126 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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/>.
* ============================================================ */
#include "certificateinfowidget.h"
#include "ui_certificateinfowidget.h"
#include <QDebug>
QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert)
{
QString commonName = cert.subjectInfo(QSslCertificate::CommonName);
QString organization = cert.subjectInfo(QSslCertificate::Organization);
if (commonName.isEmpty())
return clearCertSpecialSymbols(organization);
return clearCertSpecialSymbols(commonName);
}
QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
{
if (!string.contains("\\"))
return string;
QString n = string;
//Credits to http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/176679?help-en
n.replace("\\xC3\\x80", "A"); n.replace("\\xC3\\x81", "A"); n.replace("\\xC3\\x82", "A"); n.replace("\\xC3\\x83", "A");
n.replace("\\xC3\\x84", "A"); n.replace("\\xC3\\x85", "A"); n.replace("\\xC3\\x86", "AE"); n.replace("\\xC3\\x87", "C");
n.replace("\\xC3\\x88", "E"); n.replace("\\xC3\\x89", "E"); n.replace("\\xC3\\x8A", "E"); n.replace("\\xC3\\x8B", "E");
n.replace("\\xC3\\x8C", "I"); n.replace("\\xC3\\x8D", "I"); n.replace("\\xC3\\x8E", "I"); n.replace("\\xC3\\x8F", "I");
n.replace("\\xC3\\x90", "D"); n.replace("\\xC3\\x91", "N"); n.replace("\\xC3\\x92", "O"); n.replace("\\xC3\\x93", "O");
n.replace("\\xC3\\x94", "O"); n.replace("\\xC3\\x95", "O"); n.replace("\\xC3\\x96", "O"); n.replace("\\xC3\\x98", "O");
n.replace("\\xC3\\x99", "U"); n.replace("\\xC3\\x9A", "U"); n.replace("\\xC3\\x9B", "U"); n.replace("\\xC3\\x9C", "U");
n.replace("\\xC3\\x9D", "Y"); n.replace("\\xC3\\x9E", "P"); n.replace("\\xC3\\x9F", "ss"); n.replace("\\xC9\\x99", "e");
n.replace("\\xC3\\xA0", "a"); n.replace("\\xC3\\xA1", "a"); n.replace("\\xC3\\xA2", "a"); n.replace("\\xC3\\xA3", "a");
n.replace("\\xC3\\xA4", "a"); n.replace("\\xC3\\xA5", "a"); n.replace("\\xC3\\xA6", "ae"); n.replace("\\xC3\\xA7", "c");
n.replace("\\xC3\\xA8", "e"); n.replace("\\xC3\\xA9", "e"); n.replace("\\xC3\\xAA", "e"); n.replace("\\xC3\\xAB", "e");
n.replace("\\xC3\\xAC", "i"); n.replace("\\xC3\\xAD", "i"); n.replace("\\xC3\\xAE", "i"); n.replace("\\xC3\\xAF", "i");
n.replace("\\xC3\\xB0", "o"); n.replace("\\xC3\\xB1", "n"); n.replace("\\xC3\\xB2", "o"); n.replace("\\xC3\\xB3", "o");
n.replace("\\xC3\\xB4", "o"); n.replace("\\xC3\\xB5", "o"); n.replace("\\xC3\\xB6", "o"); n.replace("\\xC3\\xB8", "o");
n.replace("\\xC3\\xB9", "u"); n.replace("\\xC3\\xBA", "u"); n.replace("\\xC3\\xBB", "u"); n.replace("\\xC3\\xBC", "u");
n.replace("\\xC3\\xBD", "y"); n.replace("\\xC3\\xBE", "p"); n.replace("\\xC3\\xBF", "y"); n.replace("\\xC7\\xBF", "o");
n.replace("\\xC4\\x80", "A"); n.replace("\\xC4\\x81", "a"); n.replace("\\xC4\\x82", "A"); n.replace("\\xC4\\x83", "a");
n.replace("\\xC4\\x84", "A"); n.replace("\\xC4\\x85", "a"); n.replace("\\xC4\\x86", "C"); n.replace("\\xC4\\x87", "c");
n.replace("\\xC4\\x88", "C"); n.replace("\\xC4\\x89", "c"); n.replace("\\xC4\\x8A", "C"); n.replace("\\xC4\\x8B", "c");
n.replace("\\xC4\\x8C", "C"); n.replace("\\xC4\\x8D", "c"); n.replace("\\xC4\\x8E", "D"); n.replace("\\xC4\\x8F", "d");
n.replace("\\xC4\\x90", "D"); n.replace("\\xC4\\x91", "d"); n.replace("\\xC4\\x92", "E"); n.replace("\\xC4\\x93", "e");
n.replace("\\xC4\\x94", "E"); n.replace("\\xC4\\x95", "e"); n.replace("\\xC4\\x96", "E"); n.replace("\\xC4\\x97", "e");
n.replace("\\xC4\\x98", "E"); n.replace("\\xC4\\x99", "e"); n.replace("\\xC4\\x9A", "E"); n.replace("\\xC4\\x9B", "e");
n.replace("\\xC4\\x9C", "G"); n.replace("\\xC4\\x9D", "g"); n.replace("\\xC4\\x9E", "G"); n.replace("\\xC4\\x9F", "g");
n.replace("\\xC4\\xA0", "G"); n.replace("\\xC4\\xA1", "g"); n.replace("\\xC4\\xA2", "G"); n.replace("\\xC4\\xA3", "g");
n.replace("\\xC4\\xA4", "H"); n.replace("\\xC4\\xA5", "h"); n.replace("\\xC4\\xA6", "H"); n.replace("\\xC4\\xA7", "h");
n.replace("\\xC4\\xA8", "I"); n.replace("\\xC4\\xA9", "i"); n.replace("\\xC4\\xAA", "I"); n.replace("\\xC4\\xAB", "i");
n.replace("\\xC4\\xAC", "I"); n.replace("\\xC4\\xAD", "i"); n.replace("\\xC4\\xAE", "I"); n.replace("\\xC4\\xAF", "i");
n.replace("\\xC4\\xB0", "I"); n.replace("\\xC4\\xB1", "i"); n.replace("\\xC4\\xB2", "IJ"); n.replace("\\xC4\\xB3", "ij");
n.replace("\\xC4\\xB4", "J"); n.replace("\\xC4\\xB5", "j"); n.replace("\\xC4\\xB6", "K"); n.replace("\\xC4\\xB7", "k");
n.replace("\\xC4\\xB8", "k"); n.replace("\\xC4\\xB9", "L"); n.replace("\\xC4\\xBA", "l"); n.replace("\\xC4\\xBB", "L");
n.replace("\\xC4\\xBC", "l"); n.replace("\\xC4\\xBD", "L"); n.replace("\\xC4\\xBE", "l"); n.replace("\\xC4\\xBF", "L");
n.replace("\\xC5\\x80", "l"); n.replace("\\xC5\\x81", "L"); n.replace("\\xC5\\x82", "l"); n.replace("\\xC5\\x83", "N");
n.replace("\\xC5\\x84", "n"); n.replace("\\xC5\\x85", "N"); n.replace("\\xC5\\x86", "n"); n.replace("\\xC5\\x87", "N");
n.replace("\\xC5\\x88", "n"); n.replace("\\xC5\\x89", "n"); n.replace("\\xC5\\x8A", "N"); n.replace("\\xC5\\x8B", "n");
n.replace("\\xC5\\x8C", "O"); n.replace("\\xC5\\x8D", "o"); n.replace("\\xC5\\x8E", "O"); n.replace("\\xC5\\x8F", "o");
n.replace("\\xC5\\x90", "O"); n.replace("\\xC5\\x91", "o"); n.replace("\\xC5\\x92", "CE"); n.replace("\\xC5\\x93", "ce");
n.replace("\\xC5\\x94", "R"); n.replace("\\xC5\\x95", "r"); n.replace("\\xC5\\x96", "R"); n.replace("\\xC5\\x97", "r");
n.replace("\\xC5\\x98", "R"); n.replace("\\xC5\\x99", "r"); n.replace("\\xC5\\x9A", "S"); n.replace("\\xC5\\x9B", "s");
n.replace("\\xC5\\x9C", "S"); n.replace("\\xC5\\x9D", "s"); n.replace("\\xC5\\x9E", "S"); n.replace("\\xC5\\x9F", "s");
n.replace("\\xC5\\xA0", "S"); n.replace("\\xC5\\xA1", "s"); n.replace("\\xC5\\xA2", "T"); n.replace("\\xC5\\xA3", "t");
n.replace("\\xC5\\xA4", "T"); n.replace("\\xC5\\xA5", "t"); n.replace("\\xC5\\xA6", "T"); n.replace("\\xC5\\xA7", "t");
n.replace("\\xC5\\xA8", "U"); n.replace("\\xC5\\xA9", "u"); n.replace("\\xC5\\xAA", "U"); n.replace("\\xC5\\xAB", "u");
n.replace("\\xC5\\xAC", "U"); n.replace("\\xC5\\xAD", "u"); n.replace("\\xC5\\xAE", "U"); n.replace("\\xC5\\xAF", "u");
n.replace("\\xC5\\xB0", "U"); n.replace("\\xC5\\xB1", "u"); n.replace("\\xC5\\xB2", "U"); n.replace("\\xC5\\xB3", "u");
n.replace("\\xC5\\xB4", "W"); n.replace("\\xC5\\xB5", "w"); n.replace("\\xC5\\xB6", "Y"); n.replace("\\xC5\\xB7", "y");
n.replace("\\xC5\\xB8", "Y"); n.replace("\\xC5\\xB9", "Z"); n.replace("\\xC5\\xBA", "z"); n.replace("\\xC5\\xBB", "Z");
n.replace("\\xC5\\xBC", "z"); n.replace("\\xC5\\xBD", "Z"); n.replace("\\xC5\\xBE", "z"); n.replace("\\xC6\\x8F", "E");
n.replace("\\xC6\\xA0", "O"); n.replace("\\xC6\\xA1", "o"); n.replace("\\xC6\\xAF", "U"); n.replace("\\xC6\\xB0", "u");
n.replace("\\xC7\\x8D", "A"); n.replace("\\xC7\\x8E", "a"); n.replace("\\xC7\\x8F", "I"); n.replace("\\xC7\\x93", "U");
n.replace("\\xC7\\x90", "i"); n.replace("\\xC7\\x91", "O"); n.replace("\\xC7\\x92", "o"); n.replace("\\xC7\\x97", "U");
n.replace("\\xC7\\x94", "u"); n.replace("\\xC7\\x95", "U"); n.replace("\\xC7\\x96", "u"); n.replace("\\xC7\\x9B", "U");
n.replace("\\xC7\\x98", "u"); n.replace("\\xC7\\x99", "U"); n.replace("\\xC7\\x9A", "u"); n.replace("\\xC7\\xBD", "ae");
n.replace("\\xC7\\x9C", "u"); n.replace("\\xC7\\xBB", "a"); n.replace("\\xC7\\xBC", "AE"); n.replace("\\xC7\\xBE", "O");
n.replace("\\xC7\\xBA", "A");
n.replace("\\xC2\\x82", ","); // High code comma
n.replace("\\xC2\\x84", ",,"); // High code double comma
n.replace("\\xC2\\x85", "..."); // Tripple dot
n.replace("\\xC2\\x88", "^"); // High carat
n.replace("\\xC2\\x91", "\\x27"); // Forward single quote
n.replace("\\xC2\\x92", "\\x27"); // Reverse single quote
n.replace("\\xC2\\x93", "\\x22"); // Forward double quote
n.replace("\\xC2\\x94", "\\x22"); // Reverse double quote
n.replace("\\xC2\\x96", "-"); // High hyphen
n.replace("\\xC2\\x97", "--"); // Double hyphen
n.replace("\\xC2\\xA6", "|"); // Split vertical bar
n.replace("\\xC2\\xAB", "<<"); // Double less than
n.replace("\\xC2\\xBB", ">>"); // Double greater than
n.replace("\\xC2\\xBC", "1/4"); // one quarter
n.replace("\\xC2\\xBD", "1/2"); // one half
n.replace("\\xC2\\xBE", "3/4"); // three quarters
n.replace("\\xCA\\xBF", "\\x27"); // c-single quote
n.replace("\\xCC\\xA8", ""); // modifier - under curve
n.replace("\\xCC\\xB1", ""); // modifier - under line
return n;
}
QString CertificateInfoWidget::showCertInfo(const QString &string)
{
if (string.isEmpty())
return tr("<not set in certificate>");
else return string;
else return clearCertSpecialSymbols(string);
}
CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidget *parent)

View File

@ -1,3 +1,20 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 CERTIFICATEINFOWIDGET_H
#define CERTIFICATEINFOWIDGET_H
@ -18,6 +35,8 @@ public:
~CertificateInfoWidget();
static QString showCertInfo(const QString &string);
static QString clearCertSpecialSymbols(const QString &string);
static QString certificateItemText(const QSslCertificate &cert);
private:
Ui::CertificateInfoWidget *ui;

View File

@ -26,7 +26,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="SqueezeLabelV2" name="issuedToCN">
<widget class="QLabel" name="issuedToCN">
<property name="text">
<string/>
</property>
@ -40,7 +40,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="SqueezeLabelV2" name="issuedToO">
<widget class="QLabel" name="issuedToO">
<property name="text">
<string/>
</property>
@ -54,7 +54,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="SqueezeLabelV2" name="issuedToOU">
<widget class="QLabel" name="issuedToOU">
<property name="text">
<string/>
</property>
@ -68,7 +68,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="SqueezeLabelV2" name="issuedToSN">
<widget class="QLabel" name="issuedToSN">
<property name="text">
<string/>
</property>
@ -89,7 +89,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="SqueezeLabelV2" name="issuedByCN">
<widget class="QLabel" name="issuedByCN">
<property name="text">
<string/>
</property>
@ -103,7 +103,7 @@
</widget>
</item>
<item row="7" column="1">
<widget class="SqueezeLabelV2" name="issuedByO">
<widget class="QLabel" name="issuedByO">
<property name="text">
<string/>
</property>
@ -117,7 +117,7 @@
</widget>
</item>
<item row="8" column="1">
<widget class="SqueezeLabelV2" name="issuedByOU">
<widget class="QLabel" name="issuedByOU">
<property name="text">
<string/>
</property>
@ -138,7 +138,7 @@
</widget>
</item>
<item row="10" column="1">
<widget class="SqueezeLabelV2" name="validityIssuedOn">
<widget class="QLabel" name="validityIssuedOn">
<property name="text">
<string/>
</property>
@ -152,7 +152,7 @@
</widget>
</item>
<item row="11" column="1">
<widget class="SqueezeLabelV2" name="validityExpiresOn">
<widget class="QLabel" name="validityExpiresOn">
<property name="text">
<string/>
</property>
@ -160,13 +160,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SqueezeLabelV2</class>
<extends>QLabel</extends>
<header>squeezelabelv2.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -56,7 +56,6 @@ QString qz_samePartOfStrings(const QString &one, const QString &other)
}
return one.left(i);
}
#include <QDebug>
QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl)
{
@ -88,6 +87,27 @@ QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl)
return returnUrl;
}
QString qz_ensureUniqueFilename(const QString &pathToFile)
{
if (!QFile::exists(pathToFile))
return pathToFile;
QString tmpFileName = pathToFile;
int i = 1;
while (QFile::exists(tmpFileName)) {
tmpFileName = pathToFile;
int index = tmpFileName.lastIndexOf(".");
if (index == -1) {
tmpFileName.append("("+QString::number(i)+")");
} else {
tmpFileName = tmpFileName.mid(0, index) + "("+QString::number(i)+")" + tmpFileName.mid(index);
}
i++;
}
return tmpFileName;
}
QString qz_buildSystem()
{
#ifdef Q_OS_LINUX

View File

@ -34,6 +34,8 @@ void qz_centerWidgetOnScreen(QWidget* w);
QString qz_samePartOfStrings(const QString &one, const QString &other);
QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl);
QString qz_ensureUniqueFilename(const QString &name);
QString qz_buildSystem();
#endif // GLOBALFUNCTIONS_H