diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 7e75e80e1..0fb89a9e9 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -70,6 +70,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #include #include @@ -955,6 +956,17 @@ void LOOLWSD::initializeSSL() Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::SERVER_USE, sslParams); Poco::Net::SSLManager::instance().initializeServer(consoleHandler, invalidCertHandler, sslContext); + + // Init client + Poco::Net::Context::Params sslClientParams; + // TODO: Be more strict and setup SSL key/certs for owncloud server and us + sslClientParams.verificationMode = Poco::Net::Context::VERIFY_NONE; + + Poco::SharedPtr consoleClientHandler = new Poco::Net::KeyConsoleHandler(false); + Poco::SharedPtr invalidClientCertHandler = new Poco::Net::AcceptCertificateHandler(false); + + Poco::Net::Context::Ptr sslClientContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, sslClientParams); + Poco::Net::SSLManager::instance().initializeClient(consoleClientHandler, invalidClientCertHandler, sslClientContext); } void LOOLWSD::uninitialize() diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp index 1f92541c0..08bec04ac 100644 --- a/loolwsd/Storage.hpp +++ b/loolwsd/Storage.hpp @@ -16,6 +16,8 @@ #include #include +#include +#include #include #include #include @@ -195,7 +197,7 @@ public: Log::debug("Getting info for wopi uri [" + uri.toString() + "]."); Poco::URI uriObject(uri); - Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort()); + Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1); request.set("User-Agent", "LOOLWSD WOPI Agent"); session.sendRequest(request); @@ -251,7 +253,7 @@ public: const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery(); Log::debug("Wopi requesting: " + url); - Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort()); + Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, url, Poco::Net::HTTPMessage::HTTP_1_1); request.set("User-Agent", "LOOLWSD WOPI Agent"); session.sendRequest(request); @@ -292,7 +294,7 @@ public: const auto url = uriObject.getPath() + "/contents?" + uriObject.getQuery(); Log::debug("Wopi posting: " + url); - Poco::Net::HTTPClientSession session(uriObject.getHost(), uriObject.getPort()); + Poco::Net::HTTPSClientSession session(uriObject.getHost(), uriObject.getPort(), Poco::Net::SSLManager::instance().defaultClientContext()); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, url, Poco::Net::HTTPMessage::HTTP_1_1); request.set("X-WOPIOverride", "PUT"); request.setContentType("application/octet-stream");