Skip to content

Commit

Permalink
clearer errors on nil/empty config values
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Jul 16, 2024
1 parent 0a7b668 commit 1f183b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/puma/acme/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1f183b6

Please sign in to comment.