1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
22 #include <QHostAddress>
26 #include "sslinfodlg.h"
29 // ========================================
31 // ========================================
33 SslInfoDlg::SslInfoDlg(const QSslSocket *socket, QWidget *parent)
39 QSslCipher cipher = socket->sessionCipher();
41 ui.hostname->setText(socket->peerName());
42 ui.address->setText(socket->peerAddress().toString());
43 ui.encryption->setText(cipher.name());
44 ui.protocol->setText(cipher.protocolString());
46 connect(ui.certificateChain, SIGNAL(currentIndexChanged(int)), SLOT(setCurrentCert(int)));
47 foreach(const QSslCertificate &cert, socket->peerCertificateChain()) {
48 ui.certificateChain->addItem(cert.subjectInfo(QSslCertificate::CommonName));
53 void SslInfoDlg::setCurrentCert(int index)
55 QSslCertificate cert = socket()->peerCertificateChain().at(index);
56 ui.subjectCommonName->setText(cert.subjectInfo(QSslCertificate::CommonName));
57 ui.subjectOrganization->setText(cert.subjectInfo(QSslCertificate::Organization));
58 ui.subjectOrganizationalUnit->setText(cert.subjectInfo(QSslCertificate::OrganizationalUnitName));
59 ui.subjectCountry->setText(cert.subjectInfo(QSslCertificate::CountryName));
60 ui.subjectState->setText(cert.subjectInfo(QSslCertificate::StateOrProvinceName));
61 ui.subjectCity->setText(cert.subjectInfo(QSslCertificate::LocalityName));
63 ui.issuerCommonName->setText(cert.issuerInfo(QSslCertificate::CommonName));
64 ui.issuerOrganization->setText(cert.issuerInfo(QSslCertificate::Organization));
65 ui.issuerOrganizationalUnit->setText(cert.issuerInfo(QSslCertificate::OrganizationalUnitName));
66 ui.issuerCountry->setText(cert.issuerInfo(QSslCertificate::CountryName));
67 ui.issuerState->setText(cert.issuerInfo(QSslCertificate::StateOrProvinceName));
68 ui.issuerCity->setText(cert.issuerInfo(QSslCertificate::LocalityName));
70 if (socket()->sslErrors().isEmpty())
71 ui.trusted->setText(tr("Yes"));
73 QString errorString = tr("No, for the following reasons:<ul>");
74 foreach(const QSslError &error, socket()->sslErrors())
75 errorString += "<li>" + error.errorString() + "</li>";
76 errorString += "</ul>";
77 ui.trusted->setText(errorString);
80 ui.validity->setText(tr("%1 to %2").arg(cert.effectiveDate().date().toString(Qt::ISODate), cert.expiryDate().date().toString(Qt::ISODate)));
81 ui.md5Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Md5)));
82 ui.sha1Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha1)));