diff --git a/src/core/ksslerror_p.h b/src/core/ksslerror_p.h new file mode 100644 --- /dev/null +++ b/src/core/ksslerror_p.h @@ -0,0 +1,35 @@ +/* This file is part of the KDE libraries + Copyright (C) 2007, 2008 Andreas Hartmetz + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef KSSLERROR_P_H +#define KSSLERROR_P_H + +#include "ktcpsocket.h" + +class KSslErrorPrivate +{ +public: + static KSslError::Error errorFromQSslError(QSslError::SslError e); + static QSslError::SslError errorFromKSslError(KSslError::Error e); + + QSslError error; +}; + +#endif diff --git a/src/core/ktcpsocket.cpp b/src/core/ktcpsocket.cpp --- a/src/core/ktcpsocket.cpp +++ b/src/core/ktcpsocket.cpp @@ -18,6 +18,7 @@ */ #include "ktcpsocket.h" +#include "ksslerror_p.h" #include "kiocoredebug.h" #include @@ -146,92 +147,86 @@ QHash allCiphers; }; -class KSslErrorPrivate -{ -public: - static KSslError::Error errorFromQSslError(QSslError::SslError e) - { - switch (e) { - case QSslError::NoError: - return KSslError::NoError; - case QSslError::UnableToGetLocalIssuerCertificate: - case QSslError::InvalidCaCertificate: - return KSslError::InvalidCertificateAuthorityCertificate; - case QSslError::InvalidNotBeforeField: - case QSslError::InvalidNotAfterField: - case QSslError::CertificateNotYetValid: - case QSslError::CertificateExpired: - return KSslError::ExpiredCertificate; - case QSslError::UnableToDecodeIssuerPublicKey: - case QSslError::SubjectIssuerMismatch: - case QSslError::AuthorityIssuerSerialNumberMismatch: - return KSslError::InvalidCertificate; - case QSslError::SelfSignedCertificate: - case QSslError::SelfSignedCertificateInChain: - return KSslError::SelfSignedCertificate; - case QSslError::CertificateRevoked: - return KSslError::RevokedCertificate; - case QSslError::InvalidPurpose: - return KSslError::InvalidCertificatePurpose; - case QSslError::CertificateUntrusted: - return KSslError::UntrustedCertificate; - case QSslError::CertificateRejected: - return KSslError::RejectedCertificate; - case QSslError::NoPeerCertificate: - return KSslError::NoPeerCertificate; - case QSslError::HostNameMismatch: - return KSslError::HostNameMismatch; - case QSslError::UnableToVerifyFirstCertificate: - case QSslError::UnableToDecryptCertificateSignature: - case QSslError::UnableToGetIssuerCertificate: - case QSslError::CertificateSignatureFailed: - return KSslError::CertificateSignatureFailed; - case QSslError::PathLengthExceeded: - return KSslError::PathLengthExceeded; - case QSslError::UnspecifiedError: - case QSslError::NoSslSupport: - default: - return KSslError::UnknownError; - } +KSslError::Error KSslErrorPrivate::errorFromQSslError(QSslError::SslError e) +{ + switch (e) { + case QSslError::NoError: + return KSslError::NoError; + case QSslError::UnableToGetLocalIssuerCertificate: + case QSslError::InvalidCaCertificate: + return KSslError::InvalidCertificateAuthorityCertificate; + case QSslError::InvalidNotBeforeField: + case QSslError::InvalidNotAfterField: + case QSslError::CertificateNotYetValid: + case QSslError::CertificateExpired: + return KSslError::ExpiredCertificate; + case QSslError::UnableToDecodeIssuerPublicKey: + case QSslError::SubjectIssuerMismatch: + case QSslError::AuthorityIssuerSerialNumberMismatch: + return KSslError::InvalidCertificate; + case QSslError::SelfSignedCertificate: + case QSslError::SelfSignedCertificateInChain: + return KSslError::SelfSignedCertificate; + case QSslError::CertificateRevoked: + return KSslError::RevokedCertificate; + case QSslError::InvalidPurpose: + return KSslError::InvalidCertificatePurpose; + case QSslError::CertificateUntrusted: + return KSslError::UntrustedCertificate; + case QSslError::CertificateRejected: + return KSslError::RejectedCertificate; + case QSslError::NoPeerCertificate: + return KSslError::NoPeerCertificate; + case QSslError::HostNameMismatch: + return KSslError::HostNameMismatch; + case QSslError::UnableToVerifyFirstCertificate: + case QSslError::UnableToDecryptCertificateSignature: + case QSslError::UnableToGetIssuerCertificate: + case QSslError::CertificateSignatureFailed: + return KSslError::CertificateSignatureFailed; + case QSslError::PathLengthExceeded: + return KSslError::PathLengthExceeded; + case QSslError::UnspecifiedError: + case QSslError::NoSslSupport: + default: + return KSslError::UnknownError; } +} - static QSslError::SslError errorFromKSslError(KSslError::Error e) - { - switch (e) { - case KSslError::NoError: - return QSslError::NoError; - case KSslError::InvalidCertificateAuthorityCertificate: - return QSslError::InvalidCaCertificate; - case KSslError::InvalidCertificate: - return QSslError::UnableToDecodeIssuerPublicKey; - case KSslError::CertificateSignatureFailed: - return QSslError::CertificateSignatureFailed; - case KSslError::SelfSignedCertificate: - return QSslError::SelfSignedCertificate; - case KSslError::ExpiredCertificate: - return QSslError::CertificateExpired; - case KSslError::RevokedCertificate: - return QSslError::CertificateRevoked; - case KSslError::InvalidCertificatePurpose: - return QSslError::InvalidPurpose; - case KSslError::RejectedCertificate: - return QSslError::CertificateRejected; - case KSslError::UntrustedCertificate: - return QSslError::CertificateUntrusted; - case KSslError::NoPeerCertificate: - return QSslError::NoPeerCertificate; - case KSslError::HostNameMismatch: - return QSslError::HostNameMismatch; - case KSslError::PathLengthExceeded: - return QSslError::PathLengthExceeded; - case KSslError::UnknownError: - default: - return QSslError::UnspecifiedError; - } +QSslError::SslError KSslErrorPrivate::errorFromKSslError(KSslError::Error e) +{ + switch (e) { + case KSslError::NoError: + return QSslError::NoError; + case KSslError::InvalidCertificateAuthorityCertificate: + return QSslError::InvalidCaCertificate; + case KSslError::InvalidCertificate: + return QSslError::UnableToDecodeIssuerPublicKey; + case KSslError::CertificateSignatureFailed: + return QSslError::CertificateSignatureFailed; + case KSslError::SelfSignedCertificate: + return QSslError::SelfSignedCertificate; + case KSslError::ExpiredCertificate: + return QSslError::CertificateExpired; + case KSslError::RevokedCertificate: + return QSslError::CertificateRevoked; + case KSslError::InvalidCertificatePurpose: + return QSslError::InvalidPurpose; + case KSslError::RejectedCertificate: + return QSslError::CertificateRejected; + case KSslError::UntrustedCertificate: + return QSslError::CertificateUntrusted; + case KSslError::NoPeerCertificate: + return QSslError::NoPeerCertificate; + case KSslError::HostNameMismatch: + return QSslError::HostNameMismatch; + case KSslError::PathLengthExceeded: + return QSslError::PathLengthExceeded; + case KSslError::UnknownError: + default: + return QSslError::UnspecifiedError; } - - QSslError error; -}; +} KSslError::KSslError(Error errorCode, const QSslCertificate &certificate) : d(new KSslErrorPrivate())