Ejemplo n.º 1
0
static void on_handshake_complete(h2o_socket_t *sock, int status)
{
    h2o_socket_cb handshake_cb = sock->ssl->handshake.cb;
    sock->_cb.write = NULL;
    sock->ssl->handshake.cb = NULL;
    decode_ssl_input(sock);
    handshake_cb(sock, status);
}
Ejemplo n.º 2
0
static void on_handshake_complete(h2o_socket_t *sock, const char *err)
{
    h2o_socket_cb handshake_cb = sock->ssl->handshake.cb;
    sock->_cb.write = NULL;
    sock->ssl->handshake.cb = NULL;
    decode_ssl_input(sock);
    handshake_cb(sock, err);
}
Ejemplo n.º 3
0
static void on_handshake_complete(h2o_socket_t *sock, const char *err)
{
    if (err == NULL) {
        const SSL_CIPHER *cipher = SSL_get_current_cipher(sock->ssl->ssl);
        switch (SSL_CIPHER_get_id(cipher)) {
        case TLS1_CK_RSA_WITH_AES_128_GCM_SHA256:
        case TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256:
        case TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
        case TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
        case TLS1_CK_RSA_WITH_AES_256_GCM_SHA384:
        case TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384:
        case TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
        case TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
            sock->ssl->record_overhead = 5 /* header */ + 8 /* record_iv_length (RFC 5288 3) */ + 16 /* tag (RFC 5116 5.1) */;
            break;
#if defined(TLS1_CK_DHE_RSA_CHACHA20_POLY1305)
        case TLS1_CK_DHE_RSA_CHACHA20_POLY1305:
        case TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305:
        case TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305:
            sock->ssl->record_overhead = 5 /* header */ + 16 /* tag */;
            break;
#endif
        default:
            sock->ssl->record_overhead = 32; /* sufficiently large number that can hold most payloads */
            break;
        }
    }

    /* set ssl session into the cache */
    if (sock->ssl->handshake.client.session_cache != NULL) {
        if (err == NULL || err == h2o_socket_error_ssl_cert_name_mismatch) {
            SSL_SESSION *session = SSL_get1_session(sock->ssl->ssl);
            h2o_cache_set(sock->ssl->handshake.client.session_cache, h2o_now(h2o_socket_get_loop(sock)),
                          sock->ssl->handshake.client.session_cache_key, sock->ssl->handshake.client.session_cache_key_hash,
                          h2o_iovec_init(session, 1));
        }
    }

    h2o_socket_cb handshake_cb = sock->ssl->handshake.cb;
    sock->_cb.write = NULL;
    sock->ssl->handshake.cb = NULL;
    decode_ssl_input(sock);
    handshake_cb(sock, err);
}