30 #include <QtCore/QFile>
34 #include <QtCore/QDate>
57 const static strErr strError[] = {
72 for (
int i = 0; i < int(
sizeof(strError)/
sizeof(strErr)); i++) {
73 QString s = QString::fromLatin1(strError[i].str);
75 stringToSslError.insert(s, e);
76 sslErrorToString.insert(e, s);
81 QHash<QString, KSslError::Error> stringToSslError;
82 QHash<KSslError::Error, QString> sslErrorToString;
111 QString dtString = QString::fromLatin1(
"ExpireUTC ");
116 sl.append(QString::fromLatin1(
"Reject"));
119 sl.append(d->sslErrorToString.value(e));
122 if (!group.
hasKey(
"CertificatePEM"))
144 if (group.
keyList().size() < 2) {
155 foreach (
const QString &groupName, d->config.groupList()) {
156 QByteArray certDigest = groupName.toLatin1();
157 foreach (
const QString &key, d->config.group(groupName).keyList()) {
158 if (key == QLatin1String(
"CertificatePEM")) {
172 bool wasPrevDot =
true;
173 const int length = hostName.length();
174 for (
int i = 0; i < length; i++) {
175 const QChar c = hostName.at(i);
176 if (c == QLatin1Char(
'.')) {
177 if (wasPrevDot || (i + 1 == hostName.length())) {
193 *namePartsCount = partsCount;
200 const QByteArray certDigest = cert.digest().toHex();
204 bool foundHostName =
false;
206 int needlePartsCount;
210 if (group.
hasKey(needle)) {
212 if (needlePartsCount >= 1) {
213 foundHostName =
true;
219 while (--needlePartsCount >= 2) {
220 const int dotIndex = needle.indexOf(QLatin1Char(
'.'));
221 Q_ASSERT(dotIndex > 0);
222 needle.remove(0, dotIndex - 1);
223 needle[0] = QChar::fromLatin1(
'*');
224 if (group.
hasKey(needle)) {
225 foundHostName =
true;
232 if (!foundHostName) {
243 if (sl.size() >= 2) {
244 QString dtString = sl.takeFirst();
245 if (dtString.startsWith(QLatin1String(
"ExpireUTC "))) {
246 dtString.remove(0, 10);
247 expiryDt = QDateTime::fromString(dtString, Qt::ISODate);
251 if (!expiryDt.isValid() || expiryDt < QDateTime::currentDateTime()) {
255 if (group.
keyList().size() < 2) {
261 QList<KSslError::Error> ignoredErrors;
262 bool isRejected =
false;
263 foreach (
const QString &s, sl) {
264 if (s == QLatin1String(
"Reject")) {
266 ignoredErrors.clear();
269 if (!d->stringToSslError.contains(s)) {
272 ignoredErrors.append(d->stringToSslError.value(s));
284 #include "kssld_adaptor.moc"