You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/11/09 13:51:53 UTC

[couchdb] 15/15: feat: change enaabling of chttpsd to `[ssl] enable = true`

This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c850ffa889dc1f8bf562107aa07da429357bc8ef
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Nov 9 11:23:04 2018 +0100

    feat: change enaabling of chttpsd to `[ssl] enable = true`
    
    The previous configuration `[daemons] httpsd = {chttpd, start_link, [https]}`
    is also sill supported for backwards cmpatibility reasons.
---
 rel/overlay/etc/local.ini             |  6 +-----
 src/couch/src/couch_secondary_sup.erl | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/rel/overlay/etc/local.ini b/rel/overlay/etc/local.ini
index ea5467c..ecc97f4 100644
--- a/rel/overlay/etc/local.ini
+++ b/rel/overlay/etc/local.ini
@@ -52,12 +52,8 @@
 ; Basic realm="server" in order to prevent you getting logged out.
 ; require_valid_user = false
 
-[daemons]
-; enable SSL support by uncommenting the following line and supply the PEM's below.
-; the default ssl port CouchDB listens on is 6984
-; httpsd = {chttpd, start_link, [https]}
-
 [ssl]
+;enable = true
 ;cert_file = /full/path/to/server_cert.pem
 ;key_file = /full/path/to/server_key.pem
 ;password = somepassword
diff --git a/src/couch/src/couch_secondary_sup.erl b/src/couch/src/couch_secondary_sup.erl
index 255c849..9b424dc 100644
--- a/src/couch/src/couch_secondary_sup.erl
+++ b/src/couch/src/couch_secondary_sup.erl
@@ -36,6 +36,11 @@ init([]) ->
         {compaction_daemon, {couch_compaction_daemon, start_link, []}}
     ],
 
+    MaybeHttps = case https_enabled() of
+        true -> [{httpsd, {chttpd, start_link, [https]}}];
+        _False -> []
+    end,
+
     Children = SecondarySupervisors ++ [
         begin
             {Module, Fun, Args} = Spec,
@@ -48,6 +53,15 @@ init([]) ->
                 [Module]}
         end
         || {Name, Spec}
-        <- Daemons, Spec /= ""],
+        <- Daemons ++ MaybeHttps, Spec /= ""],
     {ok, {{one_for_one, 50, 3600},
         couch_epi:register_service(couch_db_epi, Children)}}.
+
+https_enabled() ->
+    % 1. [ssl] enable = true | false
+    % 2. if [daemons] httpsd == {chttpd, start_link, [https]} -> pretend true as well
+    SSLEnabled = config:get_boolean("ssl", "enable", false),
+    LegacySSL = config:get("daemons", "httpsd"),
+    LegacySSLEnabled = LegacySSL =:= "{chttpd, start_link, [https]}",
+
+    SSLEnabled orelse LegacySSLEnabled.