diff --git a/src/core/ksslerror_p.h b/src/core/ksslerror_p.h --- a/src/core/ksslerror_p.h +++ b/src/core/ksslerror_p.h @@ -27,7 +27,7 @@ class KSslErrorPrivate { public: - static KSslError::Error errorFromQSslError(QSslError::SslError e); + KIOCORE_EXPORT static KSslError::Error errorFromQSslError(QSslError::SslError e); KIOCORE_EXPORT static QSslError::SslError errorFromKSslError(KSslError::Error e); QSslError error; diff --git a/src/core/tcpslavebase.cpp b/src/core/tcpslavebase.cpp --- a/src/core/tcpslavebase.cpp +++ b/src/core/tcpslavebase.cpp @@ -26,6 +26,7 @@ #include "tcpslavebase.h" #include "kiocoredebug.h" +#include "ksslerror_p.h" #include #include @@ -108,7 +109,7 @@ for (const QSslCertificate &cert : peerCertificateChain ) { for (const KSslError &error : qAsConst(sslErrors)) { if (error.certificate() == cert) { - errorStr += QString::number(static_cast(error.error())) + QLatin1Char('\t'); + errorStr += QString::number(static_cast(KSslErrorPrivate::errorFromKSslError(error.error()))) + QLatin1Char('\t'); } } if (errorStr.endsWith(QLatin1Char('\t'))) { diff --git a/src/widgets/jobuidelegate.cpp b/src/widgets/jobuidelegate.cpp --- a/src/widgets/jobuidelegate.cpp +++ b/src/widgets/jobuidelegate.cpp @@ -362,7 +362,7 @@ sslMetaData.value(QStringLiteral("ssl_cipher")), sslMetaData.value(QStringLiteral("ssl_cipher_used_bits")).toInt(), sslMetaData.value(QStringLiteral("ssl_cipher_bits")).toInt(), - KSslInfoDialog::errorsFromString(sslMetaData.value(QStringLiteral("ssl_cert_errors")))); + KSslInfoDialog::certificateErrorsFromString(sslMetaData.value(QStringLiteral("ssl_cert_errors")))); kid->exec(); } else { result = -1; diff --git a/src/widgets/ksslinfodialog.h b/src/widgets/ksslinfodialog.h --- a/src/widgets/ksslinfodialog.h +++ b/src/widgets/ksslinfodialog.h @@ -110,7 +110,17 @@ void setMainPartEncrypted(bool); void setAuxiliaryPartsEncrypted(bool); - static QList > errorsFromString(const QString &s); +#if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 65) + /** @deprecated since 5.65, use certificateErrorsFromString */ + KIOCORE_DEPRECATED_VERSION(5, 65, "use the QSslError variant") + static QList > errorsFromString(const QString &s); // TODO KF6 remove +#endif + /** + * Converts certificate errors as provided in the "ssl_cert_errors" meta data + * to a list of QSslError::SslError values per certificate in the certificate chain. + * @since 5.65 + */ + static QList> certificateErrorsFromString(const QString &errorsString); private: void updateWhichPartsEncrypted(); diff --git a/src/widgets/ksslinfodialog.cpp b/src/widgets/ksslinfodialog.cpp --- a/src/widgets/ksslinfodialog.cpp +++ b/src/widgets/ksslinfodialog.cpp @@ -251,7 +251,7 @@ const QStringList sl2 = s.split(QLatin1Char('\t'), QString::SkipEmptyParts); for (const QString &s2 : sl2) { bool didConvert; - KSslError::Error error = static_cast(s2.toInt(&didConvert)); + KSslError::Error error = KSslErrorPrivate::errorFromQSslError(static_cast(s2.toInt(&didConvert))); if (didConvert) { certErrors.append(error); } @@ -261,3 +261,23 @@ return ret; } +//static +QList> KSslInfoDialog::certificateErrorsFromString(const QString &errorsString) +{ + const QStringList sl = errorsString.split(QLatin1Char('\n'), QString::KeepEmptyParts); + QList> ret; + ret.reserve(sl.size()); + for (const QString &s : sl) { + QList certErrors; + const QStringList sl2 = s.split(QLatin1Char('\t'), QString::SkipEmptyParts); + for (const QString &s2 : sl2) { + bool didConvert; + QSslError::SslError error = static_cast(s2.toInt(&didConvert)); + if (didConvert) { + certErrors.append(error); + } + } + ret.append(certErrors); + } + return ret; +}