Add ACME certificate management to payjoin-service#1315
Add ACME certificate management to payjoin-service#1315spacebear21 merged 2 commits intopayjoin:masterfrom
Conversation
5d27ff9 to
4583f23
Compare
Pull Request Test Coverage Report for Build 21719481218Details
💛 - Coveralls |
f63d789 to
56fe208
Compare
56fe208 to
e060a78
Compare
|
I realize payjoin-service still only listens on one port, when in reality it should probably listen on :443 with acme and :80 without it so that environments without TLS, e.g. Bitcoin Core, can still reach the directory while relying on bootstrap mechanisms other than TLS. |
There was a problem hiding this comment.
tACK on prod server but with config.toml not envvars.
My only concern is the default timeouts changing (why do this?) see inline comments below.
Environment variables like for the collection failed with getting payjoin-directory-1 | Error: invalid type: map, expected a sequence for key acme.domainswhen I did PJ_ACME_DOMAINS_0: "lets.payjo.in"
services:
payjoin-service:
image: payjoin-service:acme
environment:
# ...
PJ_ACME_DOMAINS_0: "lets.payjo.in"
PJ_ACME_CONTACT_0: "mailto:admin@example.com"and now payjoin-directory-1 | Error: invalid type: string "[\"lets.payjo.in\"]", expected a sequence for key acme.domains`` when I used PJ_ACME_DOMAINS_0: '["lets.payjo.in"]'
and even double postfix __0 instead of _0 so I'm not sure if that parser is totally right. Anyway, ended up using config.toml and it was fine.
Am I supposed to use these envvars without an index?
| listener: "[::]:0".parse().expect("valid listener address"), | ||
| storage_dir: tempdir.path().to_path_buf(), | ||
| timeout: Duration::from_secs(2), | ||
| ..Default::default() |
There was a problem hiding this comment.
This not a behavior change from 2 seconds for testing to 30 seconds default? Isn't this gonna make our tests lag in a big way?
| listener: "[::]:0".parse().expect("valid listener address"), // let OS assign a free port | ||
| storage_dir: tempdir.path().to_path_buf(), | ||
| timeout: Duration::from_secs(2), | ||
| ..Default::default() |
There was a problem hiding this comment.
same behavior change here?
There was a problem hiding this comment.
After playing on this worktree with Codex I am wondering if this was an LLM edit that got overlooked that we want to revert.
I suppose the magic number isn't explanatory, so we might be better off having a static timeout: BRIEF_TEST_TIMEOUT = Duration::from_secs(2); so that the LLM (and future human readers) don't change this. Perhaps there are more places in the repo we face this idk.
There was a problem hiding this comment.
It was a manual change actually because the LLM introduced ..Default::default(), but this caused linting issues when the acme feature is disabled (due to no other fields to default). Deleting the custom timeout shouldn't impact tests time unless something breaks so I thought it should be fine to remove. I suppose we could just manually specify edit: this turned out to be a nightmare with different feature combinations across crates, keeping acme: None behind the feature gate instead of using Default everywhere.default() seems much cleaner for now. I think the idiomatic solution would be to make a ConfigBuilder that can be initialized with all default values first and individual values modified as needed.
e060a78 to
4116ef0
Compare
|
The env var parsing was broken, I fixed it in the latest push. No need for indices, you can use comma-separated lists e.g. |
This satisfies trait bounds for AxumAcceptor in the next commit.
Add an `acme` feature flag and config section modeled after the payjoin-directory feature. This implementation uses `tokio-rustls-acme`'s AxumAcceptor following the example in https://github.com/FlorianUekermann/rustls-acme/blob/main/examples/low_level_axum.rs As a result the AcmeConfig differs slightly from the one in payjoin-directory to more closely reflect rustls-acme's AcmeConfig struct.
4116ef0 to
2f93ec8
Compare
Add an
acmefeature flag and config section modeled after the payjoin-directory feature.This implementation uses
tokio-rustls-acme's AxumAcceptor following the example inhttps://github.com/FlorianUekermann/rustls-acme/blob/main/examples/low_level_axum.rs As a result the AcmeConfig differs slightly from the one in payjoin-directory to more closely reflect rustls-acme's AcmeConfig struct.
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.