MCPcopy Create free account
hub / github.com/apache/httpd / ssl_asn1_table_set

Function ssl_asn1_table_set

modules/ssl/ssl_util.c:199–226  ·  view source on GitHub ↗

Decrypted private keys are cached to survive restarts. The cached * data must have lifetime of the process (hence malloc/free rather * than pools), and uses raw DER since the EVP_PKEY structure * internals may not survive across a module reload. */

Source from the content-addressed store, hash-verified

197 * than pools), and uses raw DER since the EVP_PKEY structure
198 * internals may not survive across a module reload. */
199ssl_asn1_t *ssl_asn1_table_set(apr_hash_t *table, const char *key,
200 EVP_PKEY *pkey)
201{
202 apr_ssize_t klen = strlen(key);
203 ssl_asn1_t *asn1 = apr_hash_get(table, key, klen);
204 apr_size_t length = i2d_PrivateKey(pkey, NULL);
205 unsigned char *p;
206
207 /* Re-use structure if cached previously. */
208 if (asn1) {
209 if (asn1->nData != length) {
210 asn1->cpData = ap_realloc(asn1->cpData, length);
211 }
212 }
213 else {
214 asn1 = ap_malloc(sizeof(*asn1));
215 asn1->source_mtime = 0; /* used as a note for encrypted private keys */
216 asn1->cpData = ap_malloc(length);
217
218 apr_hash_set(table, key, klen, asn1);
219 }
220
221 asn1->nData = length;
222 p = asn1->cpData;
223 i2d_PrivateKey(pkey, &p); /* increases p by length */
224
225 return asn1;
226}
227
228ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table,
229 const char *key)

Callers 1

Calls 2

ap_reallocFunction · 0.85
ap_mallocFunction · 0.85

Tested by

no test coverage detected