diff options
Diffstat (limited to 'Swiften/Network/BOSHConnection.cpp')
-rw-r--r-- | Swiften/Network/BOSHConnection.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp index b4ffa7d..1312a3e 100644 --- a/Swiften/Network/BOSHConnection.cpp +++ b/Swiften/Network/BOSHConnection.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2011-2017 Isode Limited. + * Copyright (c) 2011-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -27,6 +27,7 @@ #include <Swiften/StreamStack/DummyStreamLayer.h> #include <Swiften/StreamStack/TLSLayer.h> #include <Swiften/TLS/TLSContext.h> +#include <Swiften/TLS/TLSContextFactory.h> #include <Swiften/TLS/TLSOptions.h> namespace Swift { @@ -42,7 +43,8 @@ BOSHConnection::BOSHConnection(const URL& boshURL, Connector::ref connector, XML connectionReady_(false) { if (boshURL_.getScheme() == "https") { - tlsLayer_ = std::make_shared<TLSLayer>(tlsContextFactory, tlsOptions); + auto tlsContext = tlsContextFactory->createTLSContext(tlsOptions); + tlsLayer_ = std::make_shared<TLSLayer>(std::move(tlsContext)); // The following dummyLayer_ is needed as the TLSLayer will pass the decrypted data to its parent layer. // The dummyLayer_ will serve as the parent layer. dummyLayer_ = std::make_shared<DummyStreamLayer>(tlsLayer_.get()); @@ -72,27 +74,27 @@ void BOSHConnection::cancelConnector() { } void BOSHConnection::handleTLSConnected() { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); onConnectFinished(false); } void BOSHConnection::handleTLSApplicationDataRead(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); handleDataRead(std::make_shared<SafeByteArray>(data)); } void BOSHConnection::handleTLSNetowrkDataWriteRequest(const SafeByteArray& data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); connection_->write(data); } void BOSHConnection::handleRawDataRead(std::shared_ptr<SafeByteArray> data) { - SWIFT_LOG(debug) << std::endl; + SWIFT_LOG(debug); tlsLayer_->handleDataRead(*data.get()); } -void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> /* error */) { - +void BOSHConnection::handleTLSError(std::shared_ptr<TLSError> error) { + SWIFT_LOG(debug) << (error ? error->getMessage() : "Unknown TLS error"); } void BOSHConnection::writeData(const SafeByteArray& data) { @@ -121,7 +123,7 @@ void BOSHConnection::restartStream() { bool BOSHConnection::setClientCertificate(CertificateWithKey::ref cert) { if (tlsLayer_) { - SWIFT_LOG(debug) << "set client certificate" << std::endl; + SWIFT_LOG(debug) << "set client certificate"; return tlsLayer_->setClientCertificate(cert); } else { @@ -209,7 +211,7 @@ void BOSHConnection::write(const SafeByteArray& data, bool streamRestart, bool t writeData(safeHeader); pending_ = true; - SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write data: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleConnectFinished(Connection::ref connection) { @@ -273,7 +275,7 @@ void BOSHConnection::startStream(const std::string& to, unsigned long long rid) SafeByteArray safeHeader = createSafeByteArray(header.str()); onBOSHDataWritten(safeHeader); writeData(safeHeader); - SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader) << std::endl; + SWIFT_LOG(debug) << "write stream header: " << safeByteArrayToString(safeHeader); } void BOSHConnection::handleDataRead(std::shared_ptr<SafeByteArray> data) { |