| 54 | } |
| 55 | |
| 56 | int md_ocsp_prime_status(server_rec *s, apr_pool_t *p, |
| 57 | const char *id, apr_size_t id_len, const char *pem) |
| 58 | { |
| 59 | md_srv_conf_t *sc; |
| 60 | const md_t *md; |
| 61 | apr_array_header_t *chain; |
| 62 | apr_status_t rv = APR_ENOENT; |
| 63 | |
| 64 | ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, s, "ocsp prime status call for: %s", |
| 65 | s->server_hostname); |
| 66 | sc = md_config_get(s); |
| 67 | if (!staple_here(sc)) { |
| 68 | ap_log_error(APLOG_MARK, APLOG_TRACE1, 0, s, |
| 69 | "ocsp prime does not apply here: server=%s, sc=%d" |
| 70 | "ocsp=%d, conf-ocsp=%d conf-others=%d", |
| 71 | s->server_hostname, !!sc, sc? !!sc->mc->ocsp : 0, |
| 72 | md_config_geti(sc, MD_CONFIG_STAPLING), |
| 73 | md_config_geti(sc, MD_CONFIG_STAPLE_OTHERS)); |
| 74 | goto cleanup; |
| 75 | } |
| 76 | |
| 77 | md = ((sc->assigned && sc->assigned->nelts == 1)? |
| 78 | APR_ARRAY_IDX(sc->assigned, 0, const md_t*) : NULL); |
| 79 | chain = apr_array_make(p, 5, sizeof(md_cert_t*)); |
| 80 | rv = md_cert_read_chain(chain, p, pem, strlen(pem)); |
| 81 | if (APR_SUCCESS != rv) { |
| 82 | ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10268) "init stapling for: %s, " |
| 83 | "unable to parse PEM data", md? md->name : s->server_hostname); |
| 84 | goto cleanup; |
| 85 | } |
| 86 | else if (chain->nelts < 2) { |
| 87 | ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10269) "init stapling for: %s, " |
| 88 | "need at least 2 certificates in PEM data", md? md->name : s->server_hostname); |
| 89 | rv = APR_EINVAL; |
| 90 | goto cleanup; |
| 91 | } |
| 92 | |
| 93 | rv = md_ocsp_prime(sc->mc->ocsp, id, id_len, |
| 94 | APR_ARRAY_IDX(chain, 0, md_cert_t*), |
| 95 | APR_ARRAY_IDX(chain, 1, md_cert_t*), md); |
| 96 | ap_log_error(APLOG_MARK, APLOG_TRACE1, rv, s, "init stapling for: %s", |
| 97 | md? md->name : s->server_hostname); |
| 98 | |
| 99 | cleanup: |
| 100 | return (APR_SUCCESS == rv)? OK : DECLINED; |
| 101 | } |
| 102 | |
| 103 | typedef struct { |
| 104 | unsigned char *der; |
nothing calls this directly
no test coverage detected