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

Function modssl_read_cert

modules/ssl/ssl_util_ssl.c:544–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542*/
543
544apr_status_t modssl_read_cert(apr_pool_t *p,
545 const char *cert_pem, const char *key_pem,
546 pem_password_cb *cb, void *ud,
547 X509 **pcert, EVP_PKEY **pkey)
548{
549 BIO *in;
550 X509 *x = NULL;
551 EVP_PKEY *key = NULL;
552 apr_status_t rv = APR_SUCCESS;
553
554 in = BIO_new_mem_buf(cert_pem, -1);
555 if (in == NULL) {
556 rv = APR_ENOMEM;
557 goto cleanup;
558 }
559
560 x = PEM_read_bio_X509(in, NULL, cb, ud);
561 if (x == NULL) {
562 rv = APR_ENOENT;
563 goto cleanup;
564 }
565
566 BIO_free(in);
567 in = BIO_new_mem_buf(key_pem? key_pem : cert_pem, -1);
568 if (in == NULL) {
569 rv = APR_ENOMEM;
570 goto cleanup;
571 }
572 key = PEM_read_bio_PrivateKey(in, NULL, cb, ud);
573 if (key == NULL) {
574 rv = APR_ENOENT;
575 goto cleanup;
576 }
577
578cleanup:
579 if (rv == APR_SUCCESS) {
580 *pcert = x;
581 *pkey = key;
582 }
583 else {
584 *pcert = NULL;
585 *pkey = NULL;
586 if (x) X509_free(x);
587 if (key) EVP_PKEY_free(key);
588 }
589 if (in != NULL) BIO_free(in);
590 return rv;
591}
592
593apr_status_t modssl_cert_get_pem(apr_pool_t *p,
594 X509 *cert1, X509 *cert2,

Callers 1

set_challenge_credsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected