| 2145 | #ifdef HAVE_TLSEXT |
| 2146 | |
| 2147 | static apr_status_t set_challenge_creds(conn_rec *c, const char *servername, |
| 2148 | SSL *ssl, X509 *cert, EVP_PKEY *key, |
| 2149 | const char *cert_pem, const char *key_pem) |
| 2150 | { |
| 2151 | SSLConnRec *sslcon = myConnConfig(c); |
| 2152 | apr_status_t rv = APR_SUCCESS; |
| 2153 | int our_data = 0; |
| 2154 | |
| 2155 | sslcon->service_unavailable = 1; |
| 2156 | if (cert_pem) { |
| 2157 | cert = NULL; |
| 2158 | key = NULL; |
| 2159 | our_data = 1; |
| 2160 | |
| 2161 | rv = modssl_read_cert(c->pool, cert_pem, key_pem, NULL, NULL, &cert, &key); |
| 2162 | if (rv != APR_SUCCESS) { |
| 2163 | ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, c, APLOGNO(10266) |
| 2164 | "Failed to parse PEM of challenge certificate %s", |
| 2165 | servername); |
| 2166 | goto cleanup; |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | if ((SSL_use_certificate(ssl, cert) < 1)) { |
| 2171 | ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, c, APLOGNO(10086) |
| 2172 | "Failed to configure challenge certificate %s", |
| 2173 | servername); |
| 2174 | rv = APR_EGENERAL; |
| 2175 | goto cleanup; |
| 2176 | } |
| 2177 | |
| 2178 | if (!SSL_use_PrivateKey(ssl, key)) { |
| 2179 | ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, c, APLOGNO(10087) |
| 2180 | "error '%s' using Challenge key: %s", |
| 2181 | ERR_error_string(ERR_peek_last_error(), NULL), |
| 2182 | servername); |
| 2183 | rv = APR_EGENERAL; |
| 2184 | goto cleanup; |
| 2185 | } |
| 2186 | |
| 2187 | if (SSL_check_private_key(ssl) < 1) { |
| 2188 | ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, c, APLOGNO(10088) |
| 2189 | "Challenge certificate and private key %s " |
| 2190 | "do not match", servername); |
| 2191 | rv = APR_EGENERAL; |
| 2192 | goto cleanup; |
| 2193 | } |
| 2194 | |
| 2195 | cleanup: |
| 2196 | if (our_data && cert) X509_free(cert); |
| 2197 | if (our_data && key) EVP_PKEY_free(key); |
| 2198 | return APR_SUCCESS; |
| 2199 | } |
| 2200 | |
| 2201 | /* |
| 2202 | * This function sets the virtual host from an extended |
no test coverage detected