Skip to content

Commit ab9dd8e

Browse files
committed
Merged /httpd/httpd/trunk:r1929514,1929883
Update mod_md to v2.6.6 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1929884 13f79535-47bb-0310-9956-ffa450edef68
1 parent c354fde commit ab9dd8e

File tree

11 files changed

+71
-21
lines changed

11 files changed

+71
-21
lines changed

STATUS

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
183183
svn merge -c 1924267 ^/httpd/httpd/trunk .
184184
+1: rpluem, jorton, covener
185185

186-
*) mod_md: update to v2.6.5
187-
Trunk version of patch:
188-
https://svn.apache.org/r1929514
189-
Backport version for 2.4.x of patch:
190-
Trunk version of patch works
191-
svn merge -c 1929514 ^/httpd/httpd/trunk .
192-
+1: icing, covener, rpluem
193-
194186
*) mod_http2: use nghttp2 supplied lengths when checking trailers.
195187
Trunk version of patch:
196188
https://svn.apache.org/r1929517

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.

changes-entries/md_v2.6.6.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*) mod_md: update to version 2.6.6
2+
- Fix a small memory leak when using OpenSSL's BIGNUMs. [Theo Buehler]
3+
- Fix reuse of curl easy handles by resetting them. [Michael Kaufmann]

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: 7 additions & 3 deletions
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 */
@@ -1240,7 +1244,7 @@ const char *md_cert_get_serial_number(const md_cert_t *cert, apr_pool_t *p)
12401244
serial = BN_bn2hex(bn);
12411245
s = apr_pstrdup(p, serial);
12421246
OPENSSL_free((void*)serial);
1243-
OPENSSL_free((void*)bn);
1247+
BN_free(bn);
12441248
}
12451249
return s;
12461250
}
@@ -2250,7 +2254,7 @@ apr_status_t md_cert_get_ari_cert_id(const char **pari_cert_id,
22502254
memset(&ser_buf, 0, sizeof(ser_buf));
22512255
bn = ASN1_INTEGER_to_BN(serial, NULL);
22522256
sder_len = BN_bn2bin(bn, sbuf);
2253-
OPENSSL_free((void*)bn);
2257+
BN_free(bn);
22542258
if (sder_len < 1)
22552259
return APR_EINVAL;
22562260
ser_buf.len = (apr_size_t)sder_len;

modules/md/md_curl.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,19 @@ static apr_status_t internals_setup(md_http_request_t *req)
255255
rv = APR_EGENERAL;
256256
goto leave;
257257
}
258-
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
259-
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
260-
curl_easy_setopt(curl, CURLOPT_READFUNCTION, req_data_cb);
261-
curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
262-
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, resp_data_cb);
263-
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
264258
}
265259
else {
266260
md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, req->pool, "reusing curl instance from http");
261+
curl_easy_reset(curl);
267262
}
268263

264+
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_cb);
265+
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
266+
curl_easy_setopt(curl, CURLOPT_READFUNCTION, req_data_cb);
267+
curl_easy_setopt(curl, CURLOPT_READDATA, NULL);
268+
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, resp_data_cb);
269+
curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
270+
269271
internals = apr_pcalloc(req->pool, sizeof(*internals));
270272
internals->curl = curl;
271273

modules/md/md_ocsp.c

Lines changed: 2 additions & 1 deletion
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);
@@ -531,7 +532,7 @@ static const char *certid_summary(const OCSP_CERTID *certid, apr_pool_t *p)
531532
bn = ASN1_INTEGER_to_BN(aserial, NULL);
532533
s = BN_bn2hex(bn);
533534
serial = apr_pstrdup(p, s);
534-
OPENSSL_free((void*)bn);
535+
BN_free(bn);
535536
OPENSSL_free((void*)s);
536537
}
537538
return apr_psprintf(p, "certid[der=%s, issuer=%s, key=%s, serial=%s]",

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.6"
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 0x020606
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 */

0 commit comments

Comments
 (0)