| 1121 | } |
| 1122 | |
| 1123 | static apr_status_t get_certificates(server_rec *s, apr_pool_t *p, int fallback, |
| 1124 | apr_array_header_t **pcert_files, |
| 1125 | apr_array_header_t **pkey_files) |
| 1126 | { |
| 1127 | apr_status_t rv = APR_ENOENT; |
| 1128 | md_srv_conf_t *sc; |
| 1129 | md_reg_t *reg; |
| 1130 | md_store_t *store; |
| 1131 | const md_t *md; |
| 1132 | apr_array_header_t *key_files, *chain_files; |
| 1133 | const char *keyfile, *chainfile; |
| 1134 | int i; |
| 1135 | |
| 1136 | *pkey_files = *pcert_files = NULL; |
| 1137 | key_files = apr_array_make(p, 5, sizeof(const char*)); |
| 1138 | chain_files = apr_array_make(p, 5, sizeof(const char*)); |
| 1139 | |
| 1140 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(10113) |
| 1141 | "get_certificates called for vhost %s.", s->server_hostname); |
| 1142 | |
| 1143 | sc = md_config_get(s); |
| 1144 | if (!sc) { |
| 1145 | ap_log_error(APLOG_MARK, APLOG_TRACE2, 0, s, |
| 1146 | "asked for certificate of server %s which has no md config", |
| 1147 | s->server_hostname); |
| 1148 | return APR_ENOENT; |
| 1149 | } |
| 1150 | |
| 1151 | assert(sc->mc); |
| 1152 | reg = sc->mc->reg; |
| 1153 | assert(reg); |
| 1154 | |
| 1155 | sc->is_ssl = 1; |
| 1156 | |
| 1157 | if (!sc->assigned) { |
| 1158 | /* With the new hooks in mod_ssl, we are invoked for all server_rec. It is |
| 1159 | * therefore normal, when we have nothing to add here. */ |
| 1160 | return APR_ENOENT; |
| 1161 | } |
| 1162 | else if (sc->assigned->nelts != 1) { |
| 1163 | if (!fallback) { |
| 1164 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(10238) |
| 1165 | "conflict: %d MDs match Virtualhost %s which uses SSL, however " |
| 1166 | "there can be at most 1.", |
| 1167 | (int)sc->assigned->nelts, s->server_hostname); |
| 1168 | } |
| 1169 | return APR_EINVAL; |
| 1170 | } |
| 1171 | md = APR_ARRAY_IDX(sc->assigned, 0, const md_t*); |
| 1172 | |
| 1173 | if (md->cert_files && md->cert_files->nelts) { |
| 1174 | apr_array_cat(chain_files, md->cert_files); |
| 1175 | apr_array_cat(key_files, md->pkey_files); |
| 1176 | rv = APR_SUCCESS; |
| 1177 | } |
| 1178 | else { |
| 1179 | md_pkey_spec_t *spec; |
| 1180 |
no test coverage detected