Search code examples
copenssl

Difference between SSL_set_connect_state and SSL_connect


I am just starting to learn openssl for C. I am having some trouble figuring out the difference between the SSL_set_connect_state function and the SSL_connect function as they seem to do thee same thing on my system. Could someone explain what the difference is?


Solution

  • SSL_connect invokes SSL_do_handshake, which performs the actual SSL handshake after invoking SSL_set_connect_state.

    Full function:

    int SSL_connect(SSL *s)
    {
        if (s->handshake_func == NULL) {
            /* Not properly initialized yet */
            SSL_set_connect_state(s);
        }
    
        return SSL_do_handshake(s);
    }