125 outctx->filter_ctx = filter_ctx;
155 "bio_filter_out_write: flush");
169#if MODSSL_USE_OPENSSL_PRE_1_1_API
198 "BUG: %s() should not be called",
"bio_filter_out_read");
211#ifndef SSL_OP_NO_RENEGOTIATION
220 "bio_filter_out_write: %i bytes",
inl);
237#if OPENSSL_VERSION_NUMBER < 0x0009080df
264 "output bio: unhandled control %d",
cmd);
303 "BUG: %s() should not be called",
"bio_filter_out_gets");
313 "BUG: %s() should not be called",
"bio_filter_out_puts");
446 else if (
b->length == 0) {
478#ifndef SSL_OP_NO_RENEGOTIATION
553 "BUG: %s() should not be called",
"bio_filter_in_write");
562 "BUG: %s() should not be called",
"bio_filter_in_puts");
571 "BUG: %s() should not be called",
"bio_filter_in_gets");
588 "BUG: bio_filter_in_ctrl() should not be called with cmd=%i",
593#if MODSSL_USE_OPENSSL_PRE_1_1_API
669 if (
inctx->cbuf.length > 0) {
697 if (!
inctx->filter_ctx->pssl) {
794 "SSL input filter read failed.");
806 "SSL library error %d reading data",
ssl_err);
830 const char *pos =
NULL;
932 "Want read during nonblocking write");
936 "SSL output filter write failed.");
943 "SSL library error %d writing data",
ssl_err);
952 char *
reason =
"reason unknown";
956 reason =
"likely due to failed renegotiation";
976#define HTTP_ON_HTTPS_PORT \
977 "GET / HTTP/1.0" CRLF
979#define HTTP_ON_HTTPS_PORT_BUCKET(alloc) \
980 apr_bucket_immortal_create(HTTP_ON_HTTPS_PORT, \
981 sizeof(HTTP_ON_HTTPS_PORT) - 1, \
986#define MODSSL_ERROR_HTTP_ON_HTTPS (APR_OS_START_USERERR + 0)
990#define MODSSL_ERROR_BAD_GATEWAY (APR_OS_START_USERERR + 1)
1015 "SSL handshake failed: HTTP spoken on HTTPS port; "
1016 "trying to send HTML error page");
1022 sslconn->non_ssl_request = NON_SSL_SEND_REQLINE;
1025 sslconn->non_ssl_request = NON_SSL_SEND_HDR_SEP;
1034 "SSL handshake failed: sending 502");
1063 const char *
type =
"";
1115 else switch (
sslconn->shutdown_type) {
1151 "%sConnection closed to child %ld with %s shutdown "
1176 if (filter_ctx->
pssl) {
1223 "proxy-request-hostname");
1235 char *protos, *
s, *
p, *
last, *proto;
1251 "ALPN proxy protocol identifier too long: %s",
1258 if (!
strcmp(
"http/1.1", proto)) {
1268 "setting alpn protos from '%s', protolen=%d",
1271 (
unsigned char *)protos,
1274 "error setting alpn protos from '%s'",
alpn_note);
1296 "SNI extension for SSL Proxy request set to '%s'",
1300 "Failed to set SNI extension for SSL Proxy "
1309 "SSL Proxy connect failed");
1327 "SSL Proxy: Peer certificate is expired");
1339 "SSL Proxy: Peer certificate does not match "
1349 "SSL_CLIENT_S_DN_CN");
1363 "SSL Proxy: Peer certificate CN mismatch:"
1364 " Certificate CN: %s Requested hostname: %s",
1388 "SSL Proxy: Peer did not select any of our ALPN protocols [%s].",
1405 "SSL Proxy: Peer proposed ALPN protocol %s which is none "
1406 "of our proposals [%s].", proto,
alpn_note);
1454 "SSL handshake stopped: connection was closed");
1477 "SSL handshake interrupted by system "
1478 "[Hint: Stop button pressed in browser?!]");
1485 "SSL library error %d in handshake "
1520 "SSL client authentication failed, "
1521 "accepting certificate based on "
1522 "\"SSLVerifyClient optional_no_ca\" "
1532 "SSL client authentication failed: %s",
1560 "No acceptable peer certificate available");
1582 if (
f->c->aborted) {
1594 if (
sslconn->non_ssl_request == NON_SSL_SEND_REQLINE) {
1598 sslconn->non_ssl_request = NON_SSL_SEND_HDR_SEP;
1602 if (
sslconn->non_ssl_request == NON_SSL_SEND_HDR_SEP) {
1606 sslconn->non_ssl_request = NON_SSL_SET_ERROR_MSG;
1653 if (
inctx->cbuf.length
1721#define COALESCE_BYTES (AP_IOBUFSIZE)
1769 if (
bytes + buffered > 0
1786 "coalesce failed to read from %s bucket",
1817 "coalesce: failed to split data bucket");
1848 || (
ctx &&
ctx->bytes > 0))) {
1874 "unexpected %s bucket during coalesce",
1888 "coalesce failed to read from data bucket");
1893 if (
len >
sizeof ctx->buffer
1894 || (
len +
ctx->bytes >
sizeof ctx->buffer)) {
1896 "unexpected coalesced bucket data length");
1939 if (
f->c->aborted) {
1944 if (!filter_ctx->
pssl) {
2056 "could not read request body for SSL buffer");
2075 "could not read bucket for SSL buffer");
2084 "could not setaside bucket for SSL buffer");
2097 if (total > maxlen) {
2100 ") for SSL buffer", maxlen);
2138 "read from buffered SSL brigade, mode %d, "
2164 "could not partition buffered SSL brigade");
2194 "could not split line from buffered SSL brigade");
2211 "buffered SSL brigade exhausted");
2231#if MODSSL_USE_OPENSSL_PRE_1_1_API
2243 inctx->cbuf.length = 0;
2247 inctx->filter_ctx = filter_ctx;
2266#if MODSSL_USE_OPENSSL_PRE_1_1_API
2277 "Enabling non-blocking writes");
2283 filter_ctx->
pssl = ssl;
2310#define DUMP_WIDTH 16
2313 const char *
b,
int len)
2316 int i, j, rows,
trunc, pos;
2320 for (; (
len > 0) && ((
b[
len-1] ==
' ') || (
b[
len-1] ==
'\0'));
len--)
2326 "+-------------------------------------------------------------------------+");
2327 for (
i = 0 ;
i < rows;
i++) {
2328#if APR_CHARSET_EBCDIC
2354#if APR_CHARSET_EBCDIC
2366 "| %04d - <SPACES/NULS>",
len +
trunc);
2368 "+-------------------------------------------------------------------------+");
2371#define MODSSL_IO_DUMP_MAX APR_UINT16_MAX
2373#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2387#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2400#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2413#if OPENSSL_VERSION_NUMBER >= 0x30000000L
2418 const char *
dump =
"";
2421 dump =
"(Oops, no memory buffer?)";
2423 dump =
"(BIO dump follows, truncated to "
2426 dump =
"(BIO dump follows)";
2430 " bytes %s BIO#%pp [mem: %pp] %s",
2450 " bytes expected to %s on BIO#%pp [mem: %pp]",
2461#if OPENSSL_VERSION_NUMBER >= 0x30000000L
int int const char ** match
const char apr_size_t len
apr_size_t const unsigned char unsigned int unsigned int d
#define AP_BUCKET_IS_EOC(e)
#define ap_xlate_proto_from_ascii(x, y)
void ap_remove_input_filter(ap_filter_t *f)
apr_status_t ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket)
ap_filter_t * ap_add_input_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
ap_filter_rec_t * ap_register_output_filter(const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
ap_filter_t * ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c)
apr_status_t ap_filter_rec_t * ap_register_input_filter(const char *name, ap_in_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype)
apr_status_t ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
#define APLOG_CS_IS_LEVEL(c, s, level)
const unsigned char * buf
int ap_map_http_request_error(apr_status_t rv, int status)
#define APR_STATUS_IS_EINTR(s)
#define APR_STATUS_IS_TIMEUP(s)
#define APR_STATUS_IS_EAGAIN(s)
#define APR_STATUS_IS_EOF(s)
#define APR_BUCKET_REMOVE(e)
#define APR_BRIGADE_LAST(b)
#define APR_BUCKET_IS_METADATA(e)
#define APR_BRIGADE_INSERT_TAIL(b, e)
#define apr_bucket_split(e, point)
apr_file_t apr_off_t start
#define APR_BRIGADE_INSERT_HEAD(b, e)
#define APR_BUCKET_NEXT(e)
#define APR_BRIGADE_CONCAT(a, b)
#define APR_BRIGADE_EMPTY(b)
#define APR_BRIGADE_SENTINEL(b)
#define apr_bucket_delete(e)
#define APR_BUCKET_IS_EOS(e)
apr_brigade_flush void * ctx
#define apr_bucket_setaside(e, p)
#define APR_BRIGADE_FIRST(b)
#define APR_BRIGADE_CHECK_CONSISTENCY(b)
#define apr_bucket_read(e, str, len, block)
#define APR_BUCKET_PREV(e)
apr_pool_t const char apr_dbd_t const char ** error
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
apr_dbd_transaction_t int mode
const char apr_ssize_t slen
apr_memcache_server_t * server
#define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns, link, ret, name, args_decl, args_use, ok, decline)
#define HTTP_INTERNAL_SERVER_ERROR
#define HTTP_REQUEST_ENTITY_TOO_LARGE
void modssl_set_io_callbacks(SSL *ssl, conn_rec *c, server_rec *s)
#define ssl_verify_error_is_optional(errnum)
char * ssl_util_vhostid(apr_pool_t *, server_rec *)
#define X509_get_notAfter
char * ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, char *var)
void ssl_io_filter_register(apr_pool_t *p)
#define BIO_set_data(x, v)
void ssl_log_ssl_error(const char *file, int line, int level, server_rec *s)
#define X509_get_notBefore
void ssl_io_filter_init(conn_rec *c, request_rec *r, SSL *ssl)
#define BIO_set_shutdown(x, v)
#define BIO_get_shutdown(x)
#define BIO_set_init(x, v)
int ssl_io_buffer_fill(request_rec *r, apr_size_t maxlen)
#define SSL_PROTOCOL_SSLV3
@ SSL_CVERIFY_OPTIONAL_NO_CA
@ SSL_SHUTDOWN_TYPE_UNCLEAN
@ SSL_SHUTDOWN_TYPE_ACCURATE
#define MODSSL_LIBRARY_NAME
int modssl_smart_shutdown(SSL *ssl)
int ssl_run_proxy_post_handshake(conn_rec *c, SSL *ssl)
#define ap_strchr_c(s, c)
#define AP_DEBUG_ASSERT(exp)
apr_seek_where_t apr_off_t * offset
const char apr_int32_t wanted
void * memchr(const void *s, int c, size_t n)
int strcasecmp(const char *a, const char *b)
apr_vformatter_buff_t * c
apr_interval_time_t apr_int32_t * num
#define apr_pcalloc(p, size)
const void apr_size_t bytes
#define APR_RING_UNSPLICE(ep1, epN, link)
#define APR_RING_SPLICE_HEAD(hp, ep1, epN, elem, link)
#define APR_ARRAY_PUSH(ary, type)
#define APR_ARRAY_IDX(ary, i, type)
static apr_status_t send_eos(ap_filter_t *f)
static apr_status_t ssl_io_filter_buffer(ap_filter_t *f, apr_bucket_brigade *bb, ap_input_mode_t mode, apr_read_type_e block, apr_off_t bytes)
static int bio_filter_in_write(BIO *bio, const char *in, int inl)
#define MODSSL_IO_DUMP_MAX
static int bio_filter_out_pass(bio_filter_out_ctx_t *outctx)
static apr_status_t ssl_io_filter_input(ap_filter_t *f, apr_bucket_brigade *bb, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
#define MODSSL_ERROR_BAD_GATEWAY
static apr_status_t ssl_io_filter_coalesce(ap_filter_t *f, apr_bucket_brigade *bb)
static apr_status_t ssl_io_filter_output(ap_filter_t *f, apr_bucket_brigade *bb)
#define HTTP_ON_HTTPS_PORT_BUCKET(alloc)
static int bio_filter_out_write(BIO *bio, const char *in, int inl)
static int bio_filter_out_puts(BIO *bio, const char *str)
static BIO_METHOD bio_filter_in_method
static apr_status_t ssl_io_filter_cleanup(void *data)
static const char ssl_io_filter[]
static int char_buffer_write(char_buffer_t *buffer, char *in, int inl)
static apr_status_t brigade_consume(apr_bucket_brigade *bb, apr_read_type_e block, char *c, apr_size_t *len)
static apr_status_t ssl_io_input_getline(bio_filter_in_ctx_t *inctx, char *buf, apr_size_t *len)
static void ssl_io_filter_disable(SSLConnRec *sslconn, bio_filter_in_ctx_t *inctx)
static int bio_filter_destroy(BIO *bio)
static apr_status_t ssl_filter_write(ap_filter_t *f, const char *data, apr_size_t len)
static int bio_filter_out_read(BIO *bio, char *out, int outl)
static bio_filter_out_ctx_t * bio_filter_out_ctx_new(ssl_filter_ctx_t *filter_ctx, conn_rec *c)
static void ssl_io_input_add_filter(ssl_filter_ctx_t *filter_ctx, conn_rec *c, request_rec *r, SSL *ssl)
static int bio_filter_create(BIO *bio)
static int char_buffer_read(char_buffer_t *buffer, char *in, int inl)
static long modssl_io_cb(BIO *bio, int cmd, const char *argp, int argi, long argl, long rc)
static long bio_filter_in_ctrl(BIO *bio, int cmd, long num, void *ptr)
static void ssl_filter_io_shutdown(ssl_filter_ctx_t *filter_ctx, conn_rec *c, int abortive)
static BIO_METHOD bio_filter_out_method
static const char ssl_io_coalesce[]
static void ssl_io_data_dump(conn_rec *c, server_rec *s, const char *b, int len)
static APR_INLINE void set_bio_callback(BIO *bio, void *arg)
#define MODSSL_ERROR_HTTP_ON_HTTPS
static apr_status_t ssl_io_input_read(bio_filter_in_ctx_t *inctx, char *buf, apr_size_t *len)
static int bio_filter_in_puts(BIO *bio, const char *str)
static apr_status_t ssl_io_filter_handshake(ssl_filter_ctx_t *filter_ctx)
static const char ssl_io_buffer[]
static int bio_filter_in_gets(BIO *bio, char *buf, int size)
static long bio_filter_out_ctrl(BIO *bio, int cmd, long num, void *ptr)
static int bio_filter_out_gets(BIO *bio, char *buf, int size)
static int bio_filter_out_flush(BIO *bio)
static apr_status_t ssl_io_filter_error(bio_filter_in_ctx_t *inctx, apr_bucket_brigade *bb, apr_status_t status, int is_init)
static int bio_filter_in_read(BIO *bio, char *in, int inlen)
Internal interfaces private to mod_ssl.
unsigned int modssl_X509_match_name(apr_pool_t *p, X509 *x509, const char *name, unsigned int allow_wildcard, server_rec *s)
The representation of a filter chain.
apr_bucket_alloc_t * bucket_alloc
struct apr_bucket_brigade::apr_bucket_list list
const apr_bucket_type_t * type
ssl_filter_ctx_t * filter_ctx
ssl_filter_ctx_t * filter_ctx
Structure to store things which are per connection.
unsigned int ssl_check_peer_cn
unsigned int ssl_check_peer_expire
unsigned int ssl_check_peer_name
A structure that represents the current request.
struct ap_filter_t * proto_input_filters
A structure to store information for each virtual server.
ap_filter_t * pInputFilter
ap_filter_t * pOutputFilter
ap_input_mode_t
input filtering modes