Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 9c8155f

Browse files
kumagigaul
authored andcommitted
use time_t for lifespan
1 parent 72337ac commit 9c8155f

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ An absolute path in which nginx will generate and serve the CBOR-encoded certifi
6868
But make sure that the OCSP responder for the certificate is accessible from your nginx server to get OCSP responses.
6969
This directive is optional.
7070

71-
#### sxg\_expires\_seconds
71+
#### sxg\_expiry\_seconds
7272

73-
The life-span of SXG file in seconds. It must not be more than 604800 (1 weeek).
74-
This directive is optional. The default value is `86400` (1 day).
73+
The life-span of generated SXG file in seconds.
74+
It must not be bigger than 604800 (1 week).
75+
This directive is optional.
76+
The default value is `86400` (1 day).
7577

7678
### Config Example
7779

ngx_http_sxg_filter_module.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct {
3737
ngx_str_t cert_url;
3838
ngx_str_t validity_url;
3939
ngx_str_t cert_path;
40-
size_t expires_seconds;
40+
time_t expiry_seconds;
4141
sxg_signer_list_t signers;
4242
ngx_sxg_cert_chain_t cert_chain;
4343
} ngx_http_sxg_loc_conf_t;
@@ -100,9 +100,9 @@ static ngx_command_t ngx_http_sxg_commands[] = {
100100
{ngx_string("sxg_cert_path"), NGX_HTTP_SRV_CONF | NGX_CONF_TAKE1,
101101
ngx_conf_set_str_slot, NGX_HTTP_LOC_CONF_OFFSET,
102102
offsetof(ngx_http_sxg_loc_conf_t, cert_path), NULL},
103-
{ngx_string("sxg_expires_seconds"), NGX_HTTP_SRV_CONF | NGX_CONF_TAKE1,
104-
ngx_conf_set_size_slot, NGX_HTTP_LOC_CONF_OFFSET,
105-
offsetof(ngx_http_sxg_loc_conf_t, expires_seconds), NULL},
103+
{ngx_string("sxg_expiry_seconds"), NGX_HTTP_SRV_CONF | NGX_CONF_TAKE1,
104+
ngx_conf_set_sec_slot, NGX_HTTP_LOC_CONF_OFFSET,
105+
offsetof(ngx_http_sxg_loc_conf_t, expiry_seconds), NULL},
106106
ngx_null_command};
107107

108108
static ngx_http_module_t ngx_http_sxg_filter_module_ctx = {
@@ -155,7 +155,7 @@ static void* ngx_http_sxg_create_loc_conf(ngx_conf_t* cf) {
155155
slc->validity_url = (ngx_str_t){.data = NULL, .len = 0};
156156
slc->cert_path = (ngx_str_t){.data = NULL, .len = 0};
157157
slc->cert_chain = ngx_sxg_empty_cert_chain();
158-
slc->expires_seconds = NGX_CONF_UNSET_SIZE;
158+
slc->expiry_seconds = NGX_CONF_UNSET;
159159
slc->signers = sxg_empty_signer_list();
160160
return slc;
161161
}
@@ -172,8 +172,8 @@ static char* ngx_http_sxg_merge_loc_conf(ngx_conf_t* cf, void* parent,
172172
ngx_conf_merge_str_value(conf->cert_url, prev->cert_url, "");
173173
ngx_conf_merge_str_value(conf->validity_url, prev->validity_url, "");
174174
ngx_conf_merge_str_value(conf->cert_path, prev->cert_path, "");
175-
ngx_conf_merge_size_value(conf->expires_seconds, prev->expires_seconds,
176-
60 * 60 * 24); // 1 day.
175+
ngx_conf_merge_sec_value(conf->expiry_seconds, prev->expiry_seconds,
176+
60 * 60 * 24); // 1 day.
177177

178178
if (!is_valid_config(cf, conf)) {
179179
if (conf->enable) {
@@ -225,11 +225,11 @@ static char* ngx_http_sxg_merge_loc_conf(ngx_conf_t* cf, void* parent,
225225
}
226226
}
227227

228-
if (conf->expires_seconds > 60 * 60 * 24 * 7) {
228+
if (conf->expiry_seconds > 60 * 60 * 24 * 7) {
229229
// SXG life-span longer than 7 days is not allowed by spec.
230230
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
231231
"nginx-sxg-module: too long lifespan of SXG %d seconds",
232-
conf->expires_seconds);
232+
conf->expiry_seconds);
233233
return NGX_CONF_ERROR;
234234
}
235235

@@ -275,7 +275,7 @@ static bool generate_sxg(const ngx_http_request_t* req,
275275
// Set parameters.
276276
sxg_signer_t* const signer = &slc->signers.signers[0];
277277
signer->date = time(NULL);
278-
signer->expires = signer->date + slc->expires_seconds;
278+
signer->expires = signer->date + slc->expiry_seconds;
279279

280280
// Generate SXG.
281281
char* const fallback_url = construct_fallback_url(req);

0 commit comments

Comments
 (0)