[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLWSD.cpp loolwsd/Storage.hpp

Pranav Kant pranavk at collabora.com
Wed Mar 30 16:15:43 UTC 2016


 loolwsd/LOOLWSD.cpp |   14 +++++++++++++-
 loolwsd/Storage.hpp |    8 +++++---
 2 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit ba96b9595491cf3c204a2f2ebdb1f9bc9ba50c32
Author: Pranav Kant <pranavk at collabora.com>
Date:   Wed Mar 30 21:27:17 2016 +0530

    loolwsd: Setup client SSL
    
    We act as a client when we communicate with owncloud server.
    
    For time being, just accept whatever certificates owncloud server
    gives us. We might want to get more strict here in future.
    
    Change-Id: I4813d19412b66ecf57d6cdef9c3ac94fbbaa521f

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 7e75e80..0fb89a9 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -70,6 +70,7 @@ DEALINGS IN THE SOFTWARE.
 #include <Poco/Exception.h>
 #include <Poco/File.h>
 #include <Poco/FileStream.h>
+#include <Poco/Net/AcceptCertificateHandler.h>
 #include <Poco/Net/ConsoleCertificateHandler.h>
 #include <Poco/Net/Context.h>
 #include <Poco/Net/HTMLForm.h>
@@ -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<Poco::Net::PrivateKeyPassphraseHandler> consoleClientHandler = new Poco::Net::KeyConsoleHandler(false);
+    Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> 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 1f92541..08bec04 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -16,6 +16,8 @@
 #include <fstream>
 
 #include <Poco/Net/HTTPResponse.h>
+#include <Poco/Net/HTTPSClientSession.h>
+#include <Poco/Net/SSLManager.h>
 #include <Poco/StreamCopier.h>
 #include <Poco/JSON/Object.h>
 #include <Poco/JSON/Parser.h>
@@ -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");
commit 27a42affd06bb499c1e26556c832fafb81e678d3
Author: Pranav Kant <pranavk at collabora.com>
Date:   Wed Mar 30 19:23:27 2016 +0530

    loolwsd: This is a server, not client
    
    Change-Id: I8db0a73048998566b4b60a7f39fe57617b9dca8d

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index db673cc..7e75e80 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -951,7 +951,7 @@ void LOOLWSD::initializeSSL()
     sslParams.verificationMode = Poco::Net::Context::VERIFY_NONE;
 
     Poco::SharedPtr<Poco::Net::PrivateKeyPassphraseHandler> consoleHandler = new Poco::Net::KeyConsoleHandler(true);
-    Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::ConsoleCertificateHandler(false);
+    Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::ConsoleCertificateHandler(true);
 
     Poco::Net::Context::Ptr sslContext = new Poco::Net::Context(Poco::Net::Context::SERVER_USE, sslParams);
     Poco::Net::SSLManager::instance().initializeServer(consoleHandler, invalidCertHandler, sslContext);


More information about the Libreoffice-commits mailing list