Skip to content

Commit ad99392

Browse files
committed
update ECH APIs to those agreed with OpenSSL maintainers
1 parent 3462110 commit ad99392

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

modules/ssl/ssl_engine_init.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ static int load_echkeys(SSL_CTX *ctx, const char *echdir, server_rec *s, apr_poo
235235
return -1;
236236
}
237237

238+
OSSL_ECHSTORE * const es = OSSL_ECHSTORE_new(NULL, NULL);
239+
if (es == NULL) {
240+
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10507)
241+
"load_echkeys: can't alloc store");
242+
return -1;
243+
}
244+
238245
while ((apr_dir_read(&direntry, finfo_flags, dir)) == APR_SUCCESS) {
239246
const char *fname;
240247
if (direntry.filetype == APR_DIR) {
@@ -262,26 +269,38 @@ static int load_echkeys(SSL_CTX *ctx, const char *echdir, server_rec *s, apr_poo
262269
apr_finfo_t theinfo;
263270
if ( (apr_stat (&theinfo, fname, APR_FINFO_MIN, ptemp)==APR_SUCCESS) ) {
264271
keystried++;
265-
if (SSL_CTX_ech_server_enable_file(ctx, fname,
266-
SSL_ECH_USE_FOR_RETRY) != 1) {
267-
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(10508)
268-
"load_echkeys: failed for %s (could be non-fatal)",fname);
269-
} else {
272+
273+
BIO *in = BIO_new_file(fname, "r");
274+
const int is_retry_config = OSSL_ECH_FOR_RETRY;
275+
if (in != NULL
276+
&& 1 == OSSL_ECHSTORE_read_pem(es, in, is_retry_config)) {
270277
ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, s, APLOGNO(10509)
271278
"load_echkeys: worked for %s",fname);
272279
keysworked++;
273280
}
281+
else {
282+
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(10508)
283+
"load_echkeys: failed for %s (could be non-fatal)",fname);
284+
}
285+
BIO_free_all(in);
274286
}
275287

276288
}
277289
apr_dir_close(dir);
278290

279291
int keysloaded=0;
280-
if (!SSL_CTX_ech_server_get_key_status(ctx,&keysloaded)) {
292+
if (!OSSL_ECHSTORE_num_keys(es, &keysloaded)) {
281293
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10510)
282294
"SSL_CTX_ech_server_key_status failed - exiting");
283295
return -1;
284296
}
297+
if (1 != SSL_CTX_set1_echstore(ctx, es)) {
298+
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10510)
299+
"load_echkeys: SSL_CTX_set1_echstore failed");
300+
OSSL_ECHSTORE_free(es);
301+
return -1;
302+
}
303+
OSSL_ECHSTORE_free(es);
285304
if (keysworked==0) {
286305
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(10511)
287306
"load_echkeys: didn't load new keys (%d tried/failed) but we have already some (%d) - continuing",

modules/ssl/ssl_engine_kernel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ int ssl_hook_Fixup(request_rec *r)
16121612
char *outer_sni=NULL;
16131613
char buf[PATH_MAX];
16141614
memset(buf,0,PATH_MAX);
1615-
int echrv=SSL_ech_get_status((SSL*)ssl,&inner_sni,&outer_sni);
1615+
int echrv=SSL_ech_get1_status((SSL*)ssl,&inner_sni,&outer_sni);
16161616
switch (echrv) {
16171617
case SSL_ECH_STATUS_NOT_TRIED:
16181618
snprintf(buf,PATH_MAX,"not attempted");
@@ -2506,7 +2506,7 @@ unsigned int ssl_callback_ECH(SSL *ssl, const char *str)
25062506

25072507
char *inner_sni=NULL;
25082508
char *outer_sni=NULL;
2509-
int echrv=SSL_ech_get_status((SSL*)ssl,&inner_sni,&outer_sni);
2509+
int echrv=SSL_ech_get1_status((SSL*)ssl,&inner_sni,&outer_sni);
25102510
switch (echrv) {
25112511
case SSL_ECH_STATUS_NOT_TRIED:
25122512
ap_log_cerror(APLOG_MARK, APLOG_INFO, 0, c, APLOGNO(10497)

0 commit comments

Comments
 (0)