Skip to content

Commit 2f3c439

Browse files
committed
ACME: new directive to indicate TOS agreement.
RFC8555 Section 7.3: > Clients SHOULD NOT automatically agree to terms by default. Rather, > they SHOULD require some user interaction for agreement to terms. Right now this only sets the flag, the corresponding logic will appear with the client implementation.
1 parent 31fbbed commit 2f3c439

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ acme_issuer example {
5656
uri https://acme.example.com/directory;
5757
contact mailto:[email protected];
5858
state_path /var/lib/nginx/acme-example;
59+
accept_terms_of_service;
5960
}
6061
6162
acme_shared_zone zone=acme_shared:1M;
@@ -203,6 +204,20 @@ help with rate-limiting ACME servers.
203204
The directory, if configured, will contain sensitive content:
204205
the account key, the issued certificates and private keys.
205206

207+
### accept_terms_of_service
208+
209+
**Syntax:** accept_terms_of_service
210+
211+
**Default:** -
212+
213+
**Context:** acme_issuer
214+
215+
Agree to the terms under which the ACME server is to be used.
216+
217+
Some servers require the user to agree with the terms of service before
218+
registering an account. The text is usually available on the ACME server's
219+
website and the URL will be printed to the error log if necessary.
220+
206221
### acme_shared_zone
207222

208223
**Syntax:** acme_shared_zone `zone` = `name:size`

src/conf.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use core::{mem, ptr};
33

44
use nginx_sys::{
55
ngx_command_t, ngx_conf_parse, ngx_conf_t, ngx_http_core_srv_conf_t, ngx_str_t, ngx_uint_t,
6-
NGX_CONF_1MORE, NGX_CONF_BLOCK, NGX_CONF_FLAG, NGX_CONF_TAKE1, NGX_HTTP_MAIN_CONF,
7-
NGX_HTTP_MAIN_CONF_OFFSET, NGX_HTTP_SRV_CONF, NGX_HTTP_SRV_CONF_OFFSET, NGX_LOG_EMERG,
6+
NGX_CONF_1MORE, NGX_CONF_BLOCK, NGX_CONF_FLAG, NGX_CONF_NOARGS, NGX_CONF_TAKE1,
7+
NGX_HTTP_MAIN_CONF, NGX_HTTP_MAIN_CONF_OFFSET, NGX_HTTP_SRV_CONF, NGX_HTTP_SRV_CONF_OFFSET,
8+
NGX_LOG_EMERG,
89
};
910
use ngx::collections::Vec;
1011
use ngx::core::{Pool, Status, NGX_CONF_ERROR, NGX_CONF_OK};
@@ -73,7 +74,7 @@ pub static mut NGX_HTTP_ACME_COMMANDS: [ngx_command_t; 4] = [
7374
ngx_command_t::empty(),
7475
];
7576

76-
static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 9] = [
77+
static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 10] = [
7778
ngx_command_t {
7879
name: ngx_string!("uri"),
7980
type_: NGX_CONF_TAKE1 as ngx_uint_t,
@@ -138,6 +139,14 @@ static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 9] = [
138139
offset: mem::offset_of!(Issuer, state_path),
139140
post: ptr::null_mut(),
140141
},
142+
ngx_command_t {
143+
name: ngx_string!("accept_terms_of_service"),
144+
type_: NGX_CONF_NOARGS as ngx_uint_t,
145+
set: Some(cmd_issuer_set_accept_tos),
146+
conf: 0,
147+
offset: 0,
148+
post: ptr::null_mut(),
149+
},
141150
ngx_command_t::empty(),
142151
];
143152

@@ -403,6 +412,22 @@ extern "C" fn cmd_issuer_set_uri(
403412
NGX_CONF_OK
404413
}
405414

415+
extern "C" fn cmd_issuer_set_accept_tos(
416+
_cf: *mut ngx_conf_t,
417+
_cmd: *mut ngx_command_t,
418+
conf: *mut c_void,
419+
) -> *mut c_char {
420+
let issuer = unsafe { conf.cast::<Issuer>().as_mut().expect("issuer conf") };
421+
422+
if issuer.accept_tos.is_some() {
423+
return NGX_CONF_DUPLICATE;
424+
}
425+
426+
issuer.accept_tos = Some(true);
427+
428+
NGX_CONF_OK
429+
}
430+
406431
/* Methods and trait implementations */
407432

408433
impl AcmeMainConfig {

src/conf/issuer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct Issuer {
4444
pub ssl_trusted_certificate: ngx_str_t,
4545
pub ssl_verify: ngx_flag_t,
4646
pub state_path: *mut ngx_path_t,
47+
pub accept_tos: Option<bool>,
4748
// Generated fields
4849
// ngx_ssl_t stores a pointer to itself in SSL_CTX ex_data.
4950
pub ssl: Box<NgxSsl, Pool>,
@@ -87,6 +88,7 @@ impl Issuer {
8788
ssl_trusted_certificate: ngx_str_t::empty(),
8889
ssl_verify: NGX_CONF_UNSET_FLAG,
8990
state_path: ptr::null_mut(),
91+
accept_tos: None,
9092
ssl,
9193
pkey: None,
9294
orders: RbTreeMap::try_new_in(alloc)?,

t/acme_conf_issuer.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ acme_issuer example {
7272
resolver_timeout 5s;
7373
ssl_verify off;
7474
state_path %%TESTDIR%%;
75+
accept_terms_of_service;
7576
}
7677
7778
EOF

0 commit comments

Comments
 (0)