[Libreoffice-commits] online.git: wsd/ProofKey.cpp

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 6 15:05:58 UTC 2020


 wsd/ProofKey.cpp |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

New commits:
commit aaa9443eae93866f0cceb1f111d40892fe694775
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Feb 6 12:44:05 2020 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Feb 6 16:05:40 2020 +0100

    Only warn on absent proof RSA key, don't log error
    
    This reimplements commit bfb16d8831c55953b93ed54127f5aee2a2de46eb
    
    Change-Id: I834a45ba4fcb939093b179f316176df790926c4e
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88096
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/wsd/ProofKey.cpp b/wsd/ProofKey.cpp
index 32a4a05e0..b0640b10c 100644
--- a/wsd/ProofKey.cpp
+++ b/wsd/ProofKey.cpp
@@ -117,21 +117,30 @@ private:
 
 Proof::Proof()
     : m_pKey([]() -> Poco::Crypto::RSAKey* {
+        const auto keyPath = ProofKeyPath();
         try
         {
-            return new Poco::Crypto::RSAKey("", ProofKeyPath());
+            return new Poco::Crypto::RSAKey("", keyPath);
+        }
+        catch (const Poco::FileNotFoundException& e)
+        {
+            std::string msg = e.displayText() +
+                "\nNo proof-key will be present in discovery."
+                "\nIf you need to use WOPI security, generate an RSA key using this command line:"
+                "\n    ssh-keygen -t rsa -N \"\" -f \"" + keyPath + "\"";
+            LOG_WRN(msg);
         }
         catch (const Poco::Exception& e)
         {
-            LOG_WRN("Could not open proof RSA key: " << e.displayText());
+            LOG_ERR("Could not open proof RSA key: " << e.displayText());
         }
         catch (const std::exception& e)
         {
-            LOG_WRN("Could not open proof RSA key: " << e.what());
+            LOG_ERR("Could not open proof RSA key: " << e.what());
         }
         catch (...)
         {
-            LOG_WRN("Could not open proof RSA key: unknown exception");
+            LOG_ERR("Could not open proof RSA key: unknown exception");
         }
         return nullptr;
     }())
@@ -150,16 +159,7 @@ Proof::Proof()
 
 std::string Proof::ProofKeyPath()
 {
-    const std::string keyPath = LOOLWSD_CONFIGDIR "/proof_key";
-    if (!Poco::File(keyPath).exists())
-    {
-        std::string msg = "Could not find " + keyPath +
-            "\nNo proof-key will be present in discovery."
-            "\nGenerate an RSA key using this command line:"
-            "\n    ssh-keygen -t rsa -N \"\" -f \"" + keyPath + "\"";
-        LOG_WRN(msg);
-    }
-
+    static const std::string keyPath = LOOLWSD_CONFIGDIR "/proof_key";
     return keyPath;
 }
 


More information about the Libreoffice-commits mailing list