Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions modules/ssl/ssl_engine_pphrase.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ apr_status_t ssl_load_encrypted_pkey(server_rec *s, apr_pool_t *p, int idx,
if (pkey_mtime) {
ssl_asn1_t *asn1 = ssl_asn1_table_get(mc->retained->privkeys, key_id);
if (asn1 && (asn1->source_mtime == pkey_mtime)) {
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(02575)
"Reusing existing private key from %s on restart",
ppcb_arg.pkey_file);
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s,
"Reusing existing private key from %s on restart",
ppcb_arg.pkey_file);
return APR_SUCCESS;
}
}
Expand Down Expand Up @@ -338,6 +338,11 @@ apr_status_t ssl_load_encrypted_pkey(server_rec *s, apr_pool_t *p, int idx,
/* Cache the private key in the global module configuration so it
* can be used after subsequent reloads. */
asn1 = ssl_asn1_table_set(mc->retained->privkeys, key_id, pPrivateKey);
if (!asn1) {
ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
"mod_ssl: Failed to cache private key");
return ssl_die(s);
}

if (ppcb_arg.nPassPhraseDialogCur != 0) {
/* remember mtime of encrypted keys */
Expand Down Expand Up @@ -1024,4 +1029,4 @@ apr_status_t modssl_load_engine_keypair(server_rec *s,
vhostid, certid ? certid : "no cert", keyid);
return APR_ENOTIMPL;
#endif
}
}
7 changes: 6 additions & 1 deletion modules/ssl/ssl_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ ssl_asn1_t *ssl_asn1_table_set(apr_hash_t *table, const char *key,
{
apr_ssize_t klen = strlen(key);
ssl_asn1_t *asn1 = apr_hash_get(table, key, klen);
apr_size_t length = i2d_PrivateKey(pkey, NULL);
int derlen = i2d_PrivateKey(pkey, NULL);
/* Encoding the key length can only fail in pathological cases which
* cannot occur for a key which has already been loaded and used. */
ap_assert(derlen > 0);

apr_size_t length = (apr_size_t)derlen;
unsigned char *p;

/* Re-use structure if cached previously. */
Expand Down