/* This function makes serf use SSL on the connection. */ apr_status_t default_https_conn_setup(apr_socket_t *skt, serf_bucket_t **input_bkt, serf_bucket_t **output_bkt, void *setup_baton, apr_pool_t *pool) { test_baton_t *tb = setup_baton; *input_bkt = serf_bucket_socket_create(skt, tb->bkt_alloc); *input_bkt = serf_bucket_ssl_decrypt_create(*input_bkt, NULL, tb->bkt_alloc); tb->ssl_context = serf_bucket_ssl_encrypt_context_get(*input_bkt); if (output_bkt) { *output_bkt = serf_bucket_ssl_encrypt_create(*output_bkt, tb->ssl_context, tb->bkt_alloc); } if (tb->server_cert_cb) serf_ssl_server_cert_callback_set(tb->ssl_context, tb->server_cert_cb, tb); serf_ssl_set_hostname(tb->ssl_context, "localhost"); return APR_SUCCESS; }
static serf_bucket_t * s_connection_setup(apr_socket_t *skt, void *setup_ctx, apr_pool_t *UNUSED(pool)) { serf_bucket_t *c; app_ctx_t *ctx = (app_ctx_t *)setup_ctx; c = serf_bucket_socket_create(skt, ctx->bkt_alloc); if (ctx->ssl_flag) { c = serf_bucket_ssl_decrypt_create(c, ctx->ssl_ctx, ctx->bkt_alloc); if (!ctx->ssl_ctx) { ctx->ssl_ctx = serf_bucket_ssl_decrypt_context_get(c); serf_ssl_use_default_certificates(ctx->ssl_ctx); serf_ssl_server_cert_callback_set(ctx->ssl_ctx, NULL, NULL); } return c; } return c; }