Skip to content

Commit

Permalink
feat(autossl) add challenge_start_delay
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Jul 21, 2021
1 parent 1c9b2d5 commit df4ba0b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ default_config = {
storage_config = {
shm_name = 'acme',
},
-- the challenge types enabled
enabled_challenge_handlers = { 'http-01' },
-- time to wait before signaling ACME server to validate in seconds
challenge_start_delay = 0,
}
```

Expand All @@ -368,8 +372,6 @@ for each certificate (4096-bits RSA and 256-bits prime256v1 ECC). Note that
generating such key will block worker and will be especially noticable on VMs
where entropy is low.

See also [Storage Adapters](#storage-adapters) below.

Pass config table directly to ACME client as second parameter. The following example
demonstrates how to use a CA provider other than Let's Encrypt and also set
the preferred chain.
Expand All @@ -385,6 +387,12 @@ resty.acme.autossl.init({
)
```

See also [Storage Adapters](#storage-adapters) below.

When using distributed storage types, it's useful to bump up `challenge_start_delay` to allow
changes in storage to propogate around. When `challenge_start_delay` is set to 0, no wait
will be performed before start validating challenges.

### autossl.get_certkey

**syntax**: *certkey, err = autossl.get_certkey(domain, type?)*
Expand Down
8 changes: 8 additions & 0 deletions lib/resty/acme/autossl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ local default_config = {
storage_config = {
shm_name = 'acme',
},
-- the challenge types enabled
enabled_challenge_handlers = { 'http-01' },
-- time to wait before signaling ACME server to validate in seconds
challenge_start_delay = 0,
}

local domain_pkeys = {}
Expand Down Expand Up @@ -310,6 +313,11 @@ function AUTOSSL.init(autossl_config, acme_config)
acme_config.account_email = autossl_config.account_email
acme_config.enabled_challenge_handlers = autossl_config.enabled_challenge_handlers

acme_config.challenge_start_callback = function()
ngx.sleep(autossl_config.challenge_start_delay)
return true
end

-- cache in global variable
domain_key_types = autossl_config.domain_key_types
domain_key_types_count = #domain_key_types
Expand Down
2 changes: 2 additions & 0 deletions t/e2e.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ sub ::make_http_config{
domain_whitelist = setmetatable({}, { __index = function()
return true
end}),
-- bump up this slightly in test
challenge_start_delay = 5,
})
}
init_worker_by_lua_block {
Expand Down

0 comments on commit df4ba0b

Please sign in to comment.