KIO
Go to the documentation of this file.
24 #include <ksslconfig.h>
26 #include <QtCore/QRegExp>
27 #include <QtCore/QUrl>
33 class KSSLPeerInfoPrivate {
35 KSSLPeerInfoPrivate() {}
36 ~KSSLPeerInfoPrivate() { }
43 :d(new KSSLPeerInfoPrivate)
56 d->peerHost = realHost.trimmed();
57 while(d->peerHost.endsWith(
'.'))
58 d->peerHost.truncate(d->peerHost.length()-1);
60 d->peerHost = QString::fromLatin1(QUrl::toAce(d->peerHost));
66 QStringList cns = certinfo.
getValue(
"CN").split(QRegExp(
"[ \n\r]"), QString::SkipEmptyParts);
69 for (QStringList::const_iterator cn = cns.constBegin(); cn != cns.constEnd(); ++cn) {
84 kDebug(7029) <<
"Matching CN=[" << cn <<
"] to ["
85 << d->peerHost <<
"]" << endl;
88 if (QRegExp(
"[^a-zA-Z0-9\\.\\*\\-]").indexIn(cn) >= 0) {
89 kDebug(7029) <<
"CN contains invalid characters! Failing.";
94 while(cn.endsWith(
'.'))
95 cn.truncate(cn.length()-1);
102 rx.setPattern(
"[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}");
103 if (rx.exactMatch(d->peerHost))
104 return d->peerHost == cn;
107 rx.setPattern(
"^\\[.*\\]$");
108 if (rx.exactMatch(d->peerHost))
109 return d->peerHost == cn;
111 if (cn.contains(
'*')) {
114 QStringList parts = cn.split(
'.', QString::SkipEmptyParts);
116 while (parts.count() > 2)
119 if (parts.count() != 2) {
123 if (parts[0].contains(
'*') || parts[1].contains(
'*')) {
130 if (QRegExp(cn, Qt::CaseInsensitive, QRegExp::Wildcard).exactMatch(d->peerHost) &&
131 cn.split(
'.', QString::SkipEmptyParts).count() ==
132 d->peerHost.split(
'.', QString::SkipEmptyParts).count())
136 if (cn.startsWith(QLatin1String(
"*."))) {
137 QString chopped = cn.mid(2);
138 if (chopped == d->peerHost) {
147 if (cn == d->peerHost)
KSSLCertificate & getPeerCertificate()
Get a reference to the peer's certificate.
QStringList subjAltNames() const
The alternate subject name.
bool cnMatchesAddress(QString cn)
Determine if the given "common name" matches the address set with setPeerHost().
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString getValue(const QString &key) const
Get the value of an entry in the map.
const QString & peerHost() const
Returns the host we are connected to.
void setPeerHost(const QString &host=QString())
Set the host that we are connected to.
bool certMatchesAddress()
Determine if the peer's certificate matches the address set with setPeerHost().
~KSSLPeerInfo()
Destroy this instance.
QString getSubject() const
Get the subject of the certificate (X.509 map).
void reset()
Clear out the host name.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jan 30 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.