From 1f183b65e1f23c9044d5d4ef38dde007492de48f Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 16 Jul 2024 16:06:40 +0000 Subject: [PATCH 1/2] clearer errors on nil/empty config values --- lib/puma/acme/plugin.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/puma/acme/plugin.rb b/lib/puma/acme/plugin.rb index e4b293e..fc5c8e3 100644 --- a/lib/puma/acme/plugin.rb +++ b/lib/puma/acme/plugin.rb @@ -7,16 +7,20 @@ class Plugin < Puma::Plugin Plugins.register('acme', self) def start(launcher) - identifiers = launcher.options[:acme_server_names] || raise(Error, 'missing ACME server name(s)') + identifiers = launcher.options[:acme_server_names] + raise(Error, 'missing SERVER_NAMES') if !identifiers || identifiers.empty? algorithm = launcher.options.fetch(:acme_algorithm, :ecdsa) contact = launcher.options.fetch(:acme_contact, nil) directory = launcher.options.fetch(:acme_directory, DEFAULT_DIRECTORY) tos_agreed = launcher.options.fetch(:acme_tos_agreed, false) - if (eab_kid = launcher.options[:acme_eab_kid]) - eab = Eab.new(kid: eab_kid, hmac_key: launcher.options.fetch(:acme_eab_hmac_key)) - end + eab_kid = launcher.options[:acme_eab_kid] + raise(Error, 'missing ACME_KID') if !eab_kid || eab_kid.empty? + eab_hmac_key = launcher.options[:acme_eab_hmac_key] + raise(Error, 'missing ACME_HMAC_KEY') if !eab_hmac_key || eab_hmac_key.empty? + + eab = Eab.new(kid: eab_kid, hmac_key: eab_hmac_key) store = launcher.options[:acme_cache] || disk_store(launcher.options) From a9ccba716aca4a01c6b428d5cb00c4e17c8596ab Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 16 Jul 2024 16:29:32 +0000 Subject: [PATCH 2/2] only error on eab if one or the other is missing, not both --- lib/puma/acme/plugin.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puma/acme/plugin.rb b/lib/puma/acme/plugin.rb index fc5c8e3..94827b7 100644 --- a/lib/puma/acme/plugin.rb +++ b/lib/puma/acme/plugin.rb @@ -16,9 +16,9 @@ def start(launcher) tos_agreed = launcher.options.fetch(:acme_tos_agreed, false) eab_kid = launcher.options[:acme_eab_kid] - raise(Error, 'missing ACME_KID') if !eab_kid || eab_kid.empty? eab_hmac_key = launcher.options[:acme_eab_hmac_key] - raise(Error, 'missing ACME_HMAC_KEY') if !eab_hmac_key || eab_hmac_key.empty? + raise(Error, 'missing ACME_KID') if eab_hmac_key && !eab_hmac_key.empty? && (!eab_key || eab_kid.empty?) + raise(Error, 'missing ACME_HMAC_KEY') if eab_kid && !eab_kid.empty? && (!eab_hmac_key || eab_hmac_key.empty?) eab = Eab.new(kid: eab_kid, hmac_key: eab_hmac_key)