You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.0 KiB

  1. From 2504f02de752aceb5a3c1d4749032147efde8082 Mon Sep 17 00:00:00 2001
  2. From: dwmw2 <dwmw2@infradead.org>
  3. Date: Fri, 3 Feb 2017 07:40:35 +0000
  4. Subject: [PATCH] Add -sslkey option to allow separate cert/key files (#1195)
  5. ---
  6. main/domoticz.cpp | 11 +++++++++++
  7. webserver/server_settings.hpp | 2 +-
  8. 2 files changed, 12 insertions(+), 1 deletion(-)
  9. --- a/main/domoticz.cpp
  10. +++ b/main/domoticz.cpp
  11. @@ -76,6 +76,7 @@ const char *szHelp=
  12. #ifdef WWW_ENABLE_SSL
  13. "\t-sslwww port (for example -sslwww 443, or -sslwww 0 to disable https)\n"
  14. "\t-sslcert file_path (for example /opt/domoticz/server_cert.pem)\n"
  15. + "\t-sslkey file_path (if different from certificate file)\n"
  16. "\t-sslpass passphrase (to access to server private key in certificate)\n"
  17. "\t-sslmethod method (for SSL method)\n"
  18. "\t-ssloptions options (for SSL options, default is 'default_workarounds,no_sslv2,single_dh_use')\n"
  19. @@ -682,6 +683,16 @@ int main(int argc, char**argv)
  20. return 1;
  21. }
  22. secure_webserver_settings.cert_file_path = cmdLine.GetSafeArgument("-sslcert", 0, "");
  23. + secure_webserver_settings.private_key_file_path = secure_webserver_settings.cert_file_path;
  24. + }
  25. + if (cmdLine.HasSwitch("-sslkey"))
  26. + {
  27. + if (cmdLine.GetArgumentCount("-sslkey") != 1)
  28. + {
  29. + _log.Log(LOG_ERROR, "Please specify a file path for your server SSL key file");
  30. + return 1;
  31. + }
  32. + secure_webserver_settings.private_key_file_path = cmdLine.GetSafeArgument("-sslkey", 0, "");
  33. }
  34. if (cmdLine.HasSwitch("-sslpass"))
  35. {
  36. --- a/webserver/server_settings.hpp
  37. +++ b/webserver/server_settings.hpp
  38. @@ -227,7 +227,7 @@ public:
  39. // use certificate file for all usage by default
  40. certificate_chain_file_path = ssl_settings.cert_file_path;
  41. ca_cert_file_path = ssl_settings.cert_file_path;
  42. - private_key_file_path = ssl_settings.cert_file_path;
  43. + private_key_file_path = ssl_settings.private_key_file_path;
  44. tmp_dh_file_path = ssl_settings.cert_file_path;
  45. verify_file_path = ssl_settings.cert_file_path;
  46. }