diff options
author | Kevin Smith <git@kismith.co.uk> | 2012-03-23 11:54:03 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-03-23 11:54:03 (GMT) |
commit | 846c4b9d2e7ec3214a3b13bdbbce77f70fede515 (patch) | |
tree | 579bf6be3e266c8e28a7469e7547ac88fa9af3fc /Swiften/Client | |
parent | 8ccdfd958ba1e7afbeb8c5893c12f09046cb8892 (diff) | |
download | swift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.zip swift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.tar.bz2 |
Allow TLS errors to bubble further up the stackks/tlserrors
Diffstat (limited to 'Swiften/Client')
-rw-r--r-- | Swiften/Client/ClientError.h | 3 | ||||
-rw-r--r-- | Swiften/Client/CoreClient.cpp | 23 | ||||
-rw-r--r-- | Swiften/Client/UnitTest/ClientSessionTest.cpp | 4 |
3 files changed, 22 insertions, 8 deletions
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h index 2f2d2af..a4dc040 100644 --- a/Swiften/Client/ClientError.h +++ b/Swiften/Client/ClientError.h @@ -22,18 +22,21 @@ namespace Swift { NoSupportedAuthMechanismsError, UnexpectedElementError, ResourceBindError, SessionStartError, StreamError, TLSError, ClientCertificateLoadError, ClientCertificateError, + // Certifate on smartcard was removed + CertificateCardRemoved, + // Certificate verification errors UnknownCertificateError, CertificateExpiredError, CertificateNotYetValidError, CertificateSelfSignedError, CertificateRejectedError, CertificateUntrustedError, InvalidCertificatePurposeError, CertificatePathLengthExceededError, diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index 14481c6..45d80aa 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -9,18 +9,19 @@ #include <boost/bind.hpp> #include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/IDGenerator.h> #include <Swiften/Base/Log.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/Algorithm.h> #include <Swiften/Client/ClientSession.h> #include <Swiften/TLS/CertificateVerificationError.h> +#include <Swiften/TLS/TLSError.h> #include <Swiften/Network/ChainedConnector.h> #include <Swiften/Network/NetworkFactories.h> #include <Swiften/Network/ProxyProvider.h> #include <Swiften/Network/DomainNameResolveError.h> #include <Swiften/TLS/PKCS12Certificate.h> #include <Swiften/Session/BasicSessionStream.h> #include <Swiften/Session/BOSHSessionStream.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Client/ClientSessionStanzaChannel.h> @@ -211,33 +212,43 @@ void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) { break; case ClientSession::Error::TLSClientCertificateError: clientError = ClientError(ClientError::ClientCertificateError); break; case ClientSession::Error::StreamError: clientError = ClientError(ClientError::StreamError); break; } } - else if (boost::shared_ptr<SessionStream::Error> actualError = boost::dynamic_pointer_cast<SessionStream::Error>(error)) { + else if (boost::shared_ptr<TLSError> actualError = boost::dynamic_pointer_cast<TLSError>(error)) { + switch(actualError->getType()) { + case TLSError::CertificateCardRemoved: + clientError = ClientError(ClientError::CertificateCardRemoved); + break; + default: + clientError = ClientError(ClientError::TLSError); + break; + } + } + else if (boost::shared_ptr<SessionStream::SessionStreamError> actualError = boost::dynamic_pointer_cast<SessionStream::SessionStreamError>(error)) { switch(actualError->type) { - case SessionStream::Error::ParseError: + case SessionStream::SessionStreamError::ParseError: clientError = ClientError(ClientError::XMLError); break; - case SessionStream::Error::TLSError: + case SessionStream::SessionStreamError::TLSError: clientError = ClientError(ClientError::TLSError); break; - case SessionStream::Error::InvalidTLSCertificateError: + case SessionStream::SessionStreamError::InvalidTLSCertificateError: clientError = ClientError(ClientError::ClientCertificateLoadError); break; - case SessionStream::Error::ConnectionReadError: + case SessionStream::SessionStreamError::ConnectionReadError: clientError = ClientError(ClientError::ConnectionReadError); break; - case SessionStream::Error::ConnectionWriteError: + case SessionStream::SessionStreamError::ConnectionWriteError: clientError = ClientError(ClientError::ConnectionWriteError); break; } } else if (boost::shared_ptr<CertificateVerificationError> verificationError = boost::dynamic_pointer_cast<CertificateVerificationError>(error)) { switch(verificationError->getType()) { case CertificateVerificationError::UnknownError: clientError = ClientError(ClientError::UnknownCertificateError); break; diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index a6d5a3a..6793643 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -414,23 +414,23 @@ class ClientSessionTest : public CppUnit::TestFixture { virtual void setWhitespacePingEnabled(bool enabled) { whitespacePingEnabled = enabled; } virtual void resetXMPPParser() { resetCount++; } void breakConnection() { - onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::ConnectionReadError)); + onClosed(boost::make_shared<SessionStream::SessionStreamError>(SessionStream::SessionStreamError::ConnectionReadError)); } void breakTLS() { - onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::TLSError)); + onClosed(boost::make_shared<SessionStream::SessionStreamError>(SessionStream::SessionStreamError::TLSError)); } void sendStreamStart() { ProtocolHeader header; header.setTo("foo.com"); return onStreamStartReceived(header); } |