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
This commit is contained in:
parent
27a42affd0
commit
ba96b95954
2 changed files with 17 additions and 3 deletions
|
@ -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()
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue