2033
2033
/* If it is in client mode initiate SSL session
2034
2034
in connect state otherwise accept state */
2035
2035
if (objt_server(conn->target)) {
2036
2039
/* Alloc a new SSL session ctx */
2037
2040
conn->xprt_ctx = SSL_new(objt_server(conn->target)->ssl_ctx.ctx);
2038
2041
if (!conn->xprt_ctx) {
2046
conn->err_code = CO_ER_SSL_NO_MEM;
2050
/* set fd on SSL session context */
2051
if (!SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd)) {
2052
SSL_free(conn->xprt_ctx);
2053
conn->xprt_ctx = NULL;
2058
conn->err_code = CO_ER_SSL_NO_MEM;
2062
/* set connection pointer */
2063
if (!SSL_set_app_data(conn->xprt_ctx, conn)) {
2064
SSL_free(conn->xprt_ctx);
2065
conn->xprt_ctx = NULL;
2039
2070
conn->err_code = CO_ER_SSL_NO_MEM;
2043
2074
SSL_set_connect_state(conn->xprt_ctx);
2044
if (objt_server(conn->target)->ssl_ctx.reused_sess)
2045
SSL_set_session(conn->xprt_ctx, objt_server(conn->target)->ssl_ctx.reused_sess);
2047
/* set fd on SSL session context */
2048
SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd);
2050
/* set connection pointer */
2051
SSL_set_app_data(conn->xprt_ctx, conn);
2075
if (objt_server(conn->target)->ssl_ctx.reused_sess) {
2076
if(!SSL_set_session(conn->xprt_ctx, objt_server(conn->target)->ssl_ctx.reused_sess)) {
2077
SSL_SESSION_free(objt_server(conn->target)->ssl_ctx.reused_sess);
2078
objt_server(conn->target)->ssl_ctx.reused_sess = NULL;
2053
2082
/* leave init state and start handshake */
2054
2083
conn->flags |= CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN;
2060
2089
else if (objt_listener(conn->target)) {
2061
2093
/* Alloc a new SSL session ctx */
2062
2094
conn->xprt_ctx = SSL_new(objt_listener(conn->target)->bind_conf->default_ctx);
2063
2095
if (!conn->xprt_ctx) {
2100
conn->err_code = CO_ER_SSL_NO_MEM;
2104
/* set fd on SSL session context */
2105
if (!SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd)) {
2106
SSL_free(conn->xprt_ctx);
2107
conn->xprt_ctx = NULL;
2112
conn->err_code = CO_ER_SSL_NO_MEM;
2116
/* set connection pointer */
2117
if (!SSL_set_app_data(conn->xprt_ctx, conn)) {
2118
SSL_free(conn->xprt_ctx);
2119
conn->xprt_ctx = NULL;
2064
2124
conn->err_code = CO_ER_SSL_NO_MEM;
2068
2128
SSL_set_accept_state(conn->xprt_ctx);
2070
/* set fd on SSL session context */
2071
SSL_set_fd(conn->xprt_ctx, conn->t.sock.fd);
2073
/* set connection pointer */
2074
SSL_set_app_data(conn->xprt_ctx, conn);
2076
2130
/* leave init state and start handshake */
2077
2131
conn->flags |= CO_FL_SSL_WAIT_HS | CO_FL_WAIT_L6_CONN;