[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - common/Crypto.cpp configure.ac .gitignore
Jan Holesovsky
kendy at collabora.com
Fri Oct 6 09:30:52 UTC 2017
.gitignore | 1 +
common/Crypto.cpp | 21 ++-------------------
configure.ac | 21 +++++++++++++--------
3 files changed, 16 insertions(+), 27 deletions(-)
New commits:
commit 08bc292066c29bf271592e974c449628e08490e8
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Oct 6 10:54:11 2017 +0200
Compile the support key in (when configured to use one).
Change-Id: Iffff0b95b245b91d9732a774a6026a3cec2b2222
Reviewed-on: https://gerrit.libreoffice.org/43185
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/.gitignore b/.gitignore
index 1fe9d685..da612170 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ missing
stamp-h1
m4
debian/loolwsd.postinst
+common/support-public-key.hpp
# Test stuff
systemplate
diff --git a/common/Crypto.cpp b/common/Crypto.cpp
index a8e84c2d..2c125a2f 100644
--- a/common/Crypto.cpp
+++ b/common/Crypto.cpp
@@ -22,6 +22,7 @@
#include "Log.hpp"
#include "Crypto.hpp"
+#include "support-public-key.hpp"
using namespace Poco;
using namespace Poco::Crypto;
@@ -82,27 +83,9 @@ bool SupportKey::verify()
return false;
}
- std::ifstream pubStream;
- std::string supportKeyFilename =
-#if ENABLE_DEBUG
- SUPPORT_KEY_FILE
-#else
- LOOLWSD_CONFIGDIR "/" SUPPORT_KEY_FILE
-#endif
- ;
+ std::istringstream pubStream(SUPPORT_PUBLIC_KEY);
try {
- pubStream.open(supportKeyFilename, std::ifstream::in);
- if (pubStream.fail())
- {
- LOG_ERR("Failed to open support public key '" << supportKeyFilename << "'.");
- return false;
- }
- } catch (...) {
- LOG_ERR("Exception opening public key '" << supportKeyFilename << "'.");
- return false;
- }
- try {
RSAKey keyPub(&pubStream);
RSADigestEngine rsaEngine(keyPub, RSADigestEngine::DigestType::DIGEST_SHA1);
rsaEngine.update(_impl->_data);
diff --git a/configure.ac b/configure.ac
index 19348d73..3b082a53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,8 +96,8 @@ AC_ARG_ENABLE([ssl],
AS_HELP_STRING([--disable-ssl],
[Compile without SSL support]))
-AC_ARG_WITH([support-key],
- AS_HELP_STRING([--with-support-key=<support-key-name.pub>],
+AC_ARG_WITH([support-public-key],
+ AS_HELP_STRING([--with-support-public-key=<public-key-name.pub>],
[Implements signed key with expiration required for support. Almost certainly you don not want to use this.]))
AC_ARG_WITH([max-connections],
@@ -294,13 +294,18 @@ fi
AC_SUBST(ENABLE_SSL)
-SUPPORT_KEY_FILE=
-AS_IF([test "x$with_support_key" != "x"],
- [AC_DEFINE([ENABLE_SUPPORT_KEY],1,[Whether to enable support key])
- AC_DEFINE_UNQUOTED([SUPPORT_KEY_FILE],[["$with_support_key"]],[LibreOffice Online WebSocket server version])],
- [AC_DEFINE([ENABLE_SUPPORT_KEY],0,[Whether to enable support key])])
+if test "x$with_support_public_key" != "x"; then
+ AC_DEFINE([ENABLE_SUPPORT_KEY],1,[Whether to enable support key])
+
+ # generate the public key include
+ echo -e "#ifndef INCLUDED_SUPPORT_PUBLIC_KEY_HPP\n#define INCLUDED_SUPPORT_PUBLIC_KEY_HPP\n#include <string>\nconst static std::string SUPPORT_PUBLIC_KEY(" > "${srcdir}/common/support-public-key.hpp"
+ sed 's/\(.*\)/"\1\\n"/' "$with_support_public_key" >> "${srcdir}/common/support-public-key.hpp"
+ echo -e ");\n#endif" >> "${srcdir}/common/support-public-key.hpp"
+else
+ AC_DEFINE([ENABLE_SUPPORT_KEY],0,[Whether to enable support key])
+ rm -f "${srcdir}/common/support-public-key.hpp"
+fi
AC_SUBST(ENABLE_SUPPORT_KEY)
-AC_SUBST(SUPPORT_KEY_FILE)
LIBS="$LIBS -lPocoNet${POCO_DEBUG_SUFFIX} -lPocoUtil${POCO_DEBUG_SUFFIX} -lPocoJSON${POCO_DEBUG_SUFFIX} -lPocoFoundation${POCO_DEBUG_SUFFIX} -lPocoXML${POCO_DEBUG_SUFFIX} -lPocoNetSSL${POCO_DEBUG_SUFFIX} -lPocoCrypto${POCO_DEBUG_SUFFIX}"
More information about the Libreoffice-commits
mailing list