1 /***************************************************************************
2 * Copyright (C) 2009 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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));
52 void SslInfoDlg::setCurrentCert(int index) {
53 QSslCertificate cert = socket()->peerCertificateChain().at(index);
54 ui.subjectCommonName->setText(cert.subjectInfo(QSslCertificate::CommonName));
55 ui.subjectOrganization->setText(cert.subjectInfo(QSslCertificate::Organization));
56 ui.subjectOrganizationalUnit->setText(cert.subjectInfo(QSslCertificate::OrganizationalUnitName));
57 ui.subjectCountry->setText(cert.subjectInfo(QSslCertificate::CountryName));
58 ui.subjectState->setText(cert.subjectInfo(QSslCertificate::StateOrProvinceName));
59 ui.subjectCity->setText(cert.subjectInfo(QSslCertificate::LocalityName));
61 ui.issuerCommonName->setText(cert.issuerInfo(QSslCertificate::CommonName));
62 ui.issuerOrganization->setText(cert.issuerInfo(QSslCertificate::Organization));
63 ui.issuerOrganizationalUnit->setText(cert.issuerInfo(QSslCertificate::OrganizationalUnitName));
64 ui.issuerCountry->setText(cert.issuerInfo(QSslCertificate::CountryName));
65 ui.issuerState->setText(cert.issuerInfo(QSslCertificate::StateOrProvinceName));
66 ui.issuerCity->setText(cert.issuerInfo(QSslCertificate::LocalityName));
68 if(socket()->sslErrors().isEmpty())
69 ui.trusted->setText(tr("Yes"));
71 QString errorString = tr("No, for the following reasons:<ul>");
72 foreach(const QSslError &error, socket()->sslErrors())
73 errorString += "<li>" + error.errorString() + "</li>";
74 errorString += "</ul>";
75 ui.trusted->setText(errorString);
78 ui.validity->setText(tr("%1 to %2").arg(cert.effectiveDate().date().toString(Qt::ISODate), cert.expiryDate().date().toString(Qt::ISODate)));
79 ui.md5Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Md5)));
80 ui.sha1Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha1)));