Changeset View
Changeset View
Standalone View
Standalone View
src/core/ksslcertificatemanager.cpp
Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Line(s) | 304 | if (!QFile::remove(userCertDir + QString::fromLatin1(old.certHash))) { | |||
---|---|---|---|---|---|
308 | // the rest of the code will work fine because it loads all certificate files from | 308 | // the rest of the code will work fine because it loads all certificate files from | ||
309 | // userCertDir without asking for the name, we just can't remove the certificate using | 309 | // userCertDir without asking for the name, we just can't remove the certificate using | ||
310 | // its digest as filename - so search the whole directory. | 310 | // its digest as filename - so search the whole directory. | ||
311 | // if the certificate was added with the digest as name *and* with a different name, we | 311 | // if the certificate was added with the digest as name *and* with a different name, we | ||
312 | // still fail to remove it completely at first try - BAD USER! BAD! | 312 | // still fail to remove it completely at first try - BAD USER! BAD! | ||
313 | 313 | | |||
314 | bool removed = false; | 314 | bool removed = false; | ||
315 | QDir dir(userCertDir); | 315 | QDir dir(userCertDir); | ||
316 | foreach (const QString &certFilename, dir.entryList(QDir::Files)) { | 316 | const QStringList dirList = dir.entryList(QDir::Files); | ||
317 | for (const QString &certFilename : dirList) { | ||||
317 | const QString certPath = userCertDir + certFilename; | 318 | const QString certPath = userCertDir + certFilename; | ||
318 | QList<QSslCertificate> certs = QSslCertificate::fromPath(certPath); | 319 | QList<QSslCertificate> certs = QSslCertificate::fromPath(certPath); | ||
319 | 320 | | |||
320 | if (!certs.isEmpty() && certs.at(0).digest().toHex() == old.certHash) { | 321 | if (!certs.isEmpty() && certs.at(0).digest().toHex() == old.certHash) { | ||
321 | if (QFile::remove(certPath)) { | 322 | if (QFile::remove(certPath)) { | ||
322 | removed = true; | 323 | removed = true; | ||
323 | } else { | 324 | } else { | ||
324 | // maybe the file is readable but not writable | 325 | // maybe the file is readable but not writable | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 357 | { | |||
394 | isCertListLoaded = false; | 395 | isCertListLoaded = false; | ||
395 | loadDefaultCaCertificates(); | 396 | loadDefaultCaCertificates(); | ||
396 | } | 397 | } | ||
397 | 398 | | |||
398 | QList<KSslCaCertificate> KSslCertificateManagerPrivate::allCertificates() const | 399 | QList<KSslCaCertificate> KSslCertificateManagerPrivate::allCertificates() const | ||
399 | { | 400 | { | ||
400 | //qDebug() << Q_FUNC_INFO; | 401 | //qDebug() << Q_FUNC_INFO; | ||
401 | QList<KSslCaCertificate> ret; | 402 | QList<KSslCaCertificate> ret; | ||
402 | foreach (const QSslCertificate &cert, deduplicate(QSslConfiguration::systemCaCertificates())) { | 403 | const QList<QSslCertificate> list = deduplicate(QSslConfiguration::systemCaCertificates()); | ||
404 | for (const QSslCertificate &cert : list) { | ||||
403 | ret += KSslCaCertificate(cert, KSslCaCertificate::SystemStore, false); | 405 | ret += KSslCaCertificate(cert, KSslCaCertificate::SystemStore, false); | ||
404 | } | 406 | } | ||
405 | 407 | | |||
406 | foreach (const QSslCertificate &cert, QSslCertificate::fromPath(userCertDir + QLatin1Char('*'), | 408 | const QList<QSslCertificate> userList = QSslCertificate::fromPath(userCertDir + QLatin1Char('*'), QSsl::Pem, | ||
407 | QSsl::Pem, QRegExp::Wildcard)) { | 409 | QRegExp::Wildcard); | ||
410 | for (const QSslCertificate &cert : userList) { | ||||
dfaure: `userList` would be a better variable name | |||||
408 | ret += KSslCaCertificate(cert, KSslCaCertificate::UserStore, false); | 411 | ret += KSslCaCertificate(cert, KSslCaCertificate::UserStore, false); | ||
409 | } | 412 | } | ||
410 | 413 | | |||
411 | KConfig config(QStringLiteral("ksslcablacklist"), KConfig::SimpleConfig); | 414 | KConfig config(QStringLiteral("ksslcablacklist"), KConfig::SimpleConfig); | ||
412 | KConfigGroup group = config.group("Blacklist of CA Certificates"); | 415 | KConfigGroup group = config.group("Blacklist of CA Certificates"); | ||
413 | for (KSslCaCertificate &cert : ret) { | 416 | for (KSslCaCertificate &cert : ret) { | ||
414 | if (group.hasKey(cert.certHash.constData())) { | 417 | if (group.hasKey(cert.certHash.constData())) { | ||
415 | cert.isBlacklisted = true; | 418 | cert.isBlacklisted = true; | ||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
userList would be a better variable name