summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/BOSHConnection.cpp')
-rw-r--r--Swiften/Network/BOSHConnection.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Swiften/Network/BOSHConnection.cpp b/Swiften/Network/BOSHConnection.cpp
index b4ffa7d..aaec9f2 100644
--- a/Swiften/Network/BOSHConnection.cpp
+++ b/Swiften/Network/BOSHConnection.cpp
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
- * Copyright (c) 2011-2017 Isode Limited.
+ * Copyright (c) 2011-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Network/BOSHConnection.h>
#include <string>
#include <thread>
@@ -21,34 +21,36 @@
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Base/Concat.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Parser/BOSHBodyExtractor.h>
#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 {
BOSHConnection::BOSHConnection(const URL& boshURL, Connector::ref connector, XMLParserFactory* parserFactory, TLSContextFactory* tlsContextFactory, const TLSOptions& tlsOptions)
: boshURL_(boshURL),
connector_(connector),
parserFactory_(parserFactory),
sid_(),
waitingForStartResponse_(false),
rid_(~0ULL),
pending_(false),
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());
}
}
BOSHConnection::~BOSHConnection() {
cancelConnector();
if (connection_) {
@@ -85,20 +87,20 @@ void BOSHConnection::handleTLSNetowrkDataWriteRequest(const SafeByteArray& data)
SWIFT_LOG(debug) << std::endl;
connection_->write(data);
}
void BOSHConnection::handleRawDataRead(std::shared_ptr<SafeByteArray> data) {
SWIFT_LOG(debug) << std::endl;
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") << std::endl;
}
void BOSHConnection::writeData(const SafeByteArray& data) {
if (tlsLayer_) {
tlsLayer_->writeData(data);
}
else {
connection_->write(data);
}