Skip to content

Commit f1a6d5e

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 af6fffb commit f1a6d5e

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ help with rate-limiting ACME servers.
203203
The directory, if configured, will contain sensitive content:
204204
the account key, the issued certificates and private keys.
205205

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

208222
**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};
@@ -71,7 +72,7 @@ pub static mut NGX_HTTP_ACME_COMMANDS: [ngx_command_t; 4] = [
7172
ngx_command_t::empty(),
7273
];
7374

74-
static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 9] = [
75+
static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 10] = [
7576
ngx_command_t {
7677
name: ngx_string!("uri"),
7778
type_: NGX_CONF_TAKE1 as ngx_uint_t,
@@ -136,6 +137,14 @@ static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 9] = [
136137
offset: mem::offset_of!(Issuer, state_path),
137138
post: ptr::null_mut(),
138139
},
140+
ngx_command_t {
141+
name: ngx_string!("terms_of_service_agreed"),
142+
type_: NGX_CONF_NOARGS as ngx_uint_t,
143+
set: Some(cmd_issuer_set_tos_agreed),
144+
conf: 0,
145+
offset: 0,
146+
post: ptr::null_mut(),
147+
},
139148
ngx_command_t::empty(),
140149
];
141150

@@ -400,6 +409,22 @@ extern "C" fn cmd_issuer_set_uri(
400409
NGX_CONF_OK
401410
}
402411

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

405430
impl AcmeMainConfig {

src/conf/issuer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct Issuer {
3838
pub ssl_trusted_certificate: ngx_str_t,
3939
pub ssl_verify: ngx_flag_t,
4040
pub state_path: *mut ngx_path_t,
41+
pub terms_of_service_agreed: Option<bool>,
4142
// Generated fields
4243
// ngx_ssl_t stores a pointer to itself in SSL_CTX ex_data.
4344
pub ssl: Box<NgxSsl, Pool>,
@@ -80,6 +81,7 @@ impl Issuer {
8081
ssl_trusted_certificate: ngx_str_t::empty(),
8182
ssl_verify: NGX_CONF_UNSET_FLAG,
8283
state_path: ptr::null_mut(),
84+
terms_of_service_agreed: None,
8385
ssl,
8486
pkey: None,
8587
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+
terms_of_service_agreed;
7576
}
7677
7778
EOF

0 commit comments

Comments
 (0)