Skip to content

Commit 7afd53d

Browse files
committed
mod_md, update tp v2.6.5
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1929514 13f79535-47bb-0310-9956-ffa450edef68
1 parent 09c2470 commit 7afd53d

File tree

8 files changed

+57
-4
lines changed

8 files changed

+57
-4
lines changed

changes-entries/md_v2.6.5.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*) mod_md: update to version 2.6.5
2+
- New directive `MDInitialDelay`, controlling how longer to wait after
3+
a server restart before checking certificates for renewal.
4+
[Michael Kaufmann]
5+
- Hardening: when build with OpenSSL older than 1.0.2 or old libressl
6+
versions, the parsing of ASN.1 time strings did not do a length check.
7+
- Hardening: when reading back OCSP responses stored in the local JSON
8+
store, missing 'valid' key led to uninitialized values, resulting in
9+
wrong refresh behaviour.

docs/manual/mod/mod_md.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,4 +1582,21 @@ MDMessageCmd /etc/apache/md-message
15821582
</p>
15831583
</usage>
15841584
</directivesynopsis>
1585+
1586+
<directivesynopsis>
1587+
<name>MDInitialDelay</name>
1588+
<description>How long to delay the first certificate check.</description>
1589+
<syntax>MDInitialDelay <var>duration</var></syntax>
1590+
<default>MDInitialDelay 0s</default>
1591+
<contextlist>
1592+
<context>server config</context>
1593+
</contextlist>
1594+
<compatibility>Available in version 2.4.66 and later</compatibility>
1595+
<usage>
1596+
<p>
1597+
The amount of time to wait after the server start to check
1598+
renewals of certificates. By default this occurs right away.
1599+
</p>
1600+
</usage>
1601+
</directivesynopsis>
15851602
</modulesynopsis>

modules/md/md_crypt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int pem_passwd(char *buf, int size, int rwflag, void *baton)
206206

207207
/* Get the apr time (micro seconds, since 1970) from an ASN1 time, as stored in X509
208208
* certificates. OpenSSL now has a utility function, but other *SSL derivatives have
209-
* not caughts up yet or chose to ignore. An alternative is implemented, we prefer
209+
* not caught up yet or chose to ignore. An alternative is implemented, we prefer
210210
* however the *SSL to maintain such things.
211211
*/
212212
static apr_time_t md_asn1_time_get(const ASN1_TIME* time)
@@ -220,6 +220,10 @@ static apr_time_t md_asn1_time_get(const ASN1_TIME* time)
220220
const char* str = (const char*) time->data;
221221
apr_size_t i = 0;
222222

223+
if ((time->length < 12) || (
224+
(time->type == V_ASN1_GENERALIZEDTIME) && time->length < 16))
225+
return 0;
226+
223227
memset(&t, 0, sizeof(t));
224228

225229
if (time->type == V_ASN1_UTCTIME) {/* two digit year */

modules/md/md_ocsp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static apr_status_t ostat_from_json(md_ocsp_cert_stat_t *pstat,
190190
md_timeperiod_t valid;
191191
apr_status_t rv = APR_ENOENT;
192192

193+
memset(&valid, 0, sizeof(valid));
193194
memset(resp_der, 0, sizeof(*resp_der));
194195
memset(resp_valid, 0, sizeof(*resp_valid));
195196
s = md_json_dups(p, json, MD_KEY_VALID, MD_KEY_FROM, NULL);

modules/md/md_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
* @macro
2828
* Version number of the md module as c string
2929
*/
30-
#define MOD_MD_VERSION "2.6.2"
30+
#define MOD_MD_VERSION "2.6.5-git"
3131

3232
/**
3333
* @macro
3434
* Numerical representation of the version number of the md module
3535
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3636
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3737
*/
38-
#define MOD_MD_VERSION_NUM 0x020602
38+
#define MOD_MD_VERSION_NUM 0x020605
3939

4040
#define MD_ACME_DEF_URL "https://acme-v02.api.letsencrypt.org/directory"
4141

modules/md/mod_md_config.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static md_mod_conf_t defmc = {
8484
"crt.sh", /* default cert checker site name */
8585
"https://crt.sh?q=", /* default cert checker site url */
8686
NULL, /* CA cert file to use */
87+
APR_TIME_C(0), /* initial cert check delay */
8788
apr_time_from_sec(MD_SECS_PER_DAY/2), /* default time between cert checks */
8889
apr_time_from_sec(30), /* minimum delay for retries */
8990
13, /* retry_failover after 14 errors, with 5s delay ~ half a day */
@@ -676,6 +677,24 @@ static const char *md_config_set_base_server(cmd_parms *cmd, void *dc, const cha
676677
return set_on_off(&config->mc->manage_base_server, value, cmd->pool);
677678
}
678679

680+
static const char *md_config_set_initial_delay(cmd_parms *cmd, void *dc, const char *value)
681+
{
682+
md_srv_conf_t *config = md_config_get(cmd->server);
683+
const char *err = md_conf_check_location(cmd, MD_LOC_NOT_MD);
684+
apr_time_t delay;
685+
686+
(void)dc;
687+
if (err) return err;
688+
if (md_duration_parse(&delay, value, "s") != APR_SUCCESS) {
689+
return "unrecognized duration format";
690+
}
691+
if (delay < 0) {
692+
return "initial delay must not be negative";
693+
}
694+
config->mc->initial_delay = delay;
695+
return NULL;
696+
}
697+
679698
static const char *md_config_set_check_interval(cmd_parms *cmd, void *dc, const char *value)
680699
{
681700
md_srv_conf_t *config = md_config_get(cmd->server);
@@ -1377,6 +1396,8 @@ const command_rec md_cmds[] = {
13771396
"Configure locking of store for updates."),
13781397
AP_INIT_TAKE1("MDMatchNames", md_config_set_match_mode, NULL, RSRC_CONF,
13791398
"Determines how DNS names are matched to vhosts."),
1399+
AP_INIT_TAKE1("MDInitialDelay", md_config_set_initial_delay, NULL, RSRC_CONF,
1400+
"How long to delay the first certificate check."),
13801401
AP_INIT_TAKE1("MDCheckInterval", md_config_set_check_interval, NULL, RSRC_CONF,
13811402
"Time between certificate checks."),
13821403
AP_INIT_TAKE1("MDProfile", md_config_set_profile, NULL, RSRC_CONF,

modules/md/mod_md_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct md_mod_conf_t {
7878
const char *cert_check_name; /* name of the linked certificate check site */
7979
const char *cert_check_url; /* url "template for" checking a certificate */
8080
const char *ca_certs; /* root certificates to use for connections */
81+
apr_time_t initial_delay; /* how long to delay the first cert renewal check */
8182
apr_time_t check_interval; /* duration between cert renewal checks */
8283
apr_time_t min_delay; /* minimum delay for retries */
8384
int retry_failover; /* number of errors to trigger CA failover */

modules/md/mod_md_drive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ apr_status_t md_renew_start_watching(md_mod_conf_t *mc, server_rec *s, apr_pool_
403403
"create md renew watchdog(%s)", MD_RENEW_WATCHDOG_NAME);
404404
return rv;
405405
}
406-
rv = wd_register_callback(dctx->watchdog, 0, dctx, run_watchdog);
406+
rv = wd_register_callback(dctx->watchdog, mc->initial_delay, dctx, run_watchdog);
407407
ap_log_error(APLOG_MARK, rv? APLOG_CRIT : APLOG_DEBUG, rv, s, APLOGNO(10067)
408408
"register md renew watchdog(%s)", MD_RENEW_WATCHDOG_NAME);
409409
return rv;

0 commit comments

Comments
 (0)