doc/designs/ddd/ddd-03-fd-blocking.c
/*
 * The application wants to create a new outgoing connection using a given
 * SSL_CTX.
 *
 * hostname is a string like "openssl.org" used for certificate validation.
 */
The application wants to create a new outgoing connection using a given
SSL_CTX.

hostname is a string like "openssl.org" used for certificate validation.
The application wants to create a new outgoing connection using a given SSL_CTX . hostname is a string like " openssl . org " used for certificate validation .
SSL *new_conn(SSL_CTX *ctx, int fd, const char *bare_hostname)
{
    SSL *ssl;
    ssl = SSL_new(ctx);
    if (ssl == NULL)
        return NULL;
    SSL_set_connect_state(ssl); 
    if (SSL_set_fd(ssl, fd) <= 0) {
        SSL_free(ssl);
        return NULL;
    }
    if (SSL_set1_host(ssl, bare_hostname) <= 0) {
        SSL_free(ssl);
        return NULL;
    }
    if (SSL_set_tlsext_host_name(ssl, bare_hostname) <= 0) {
        SSL_free(ssl);
        return NULL;
    }
    return ssl;
}
SSL * new_conn ( SSL_CTX * ctx , int fd , const char * bare_hostname ) { SSL * ssl ; ssl = SSL_new ( ctx ) ; if ( ssl == NULL ) return NULL ; SSL_set_connect_state ( ssl ) ; if ( SSL_set_fd ( ssl , fd ) <= 0 ) { SSL_free ( ssl ) ; return NULL ; } if ( SSL_set1_host ( ssl , bare_hostname ) <= 0 ) { SSL_free ( ssl ) ; return NULL ; } if ( SSL_set_tlsext_host_name ( ssl , bare_hostname ) <= 0 ) { SSL_free ( ssl ) ; return NULL ; } return ssl ; }
The application wants to create a new outgoing connection using a given
 SSL_CTX.
The application wants to create a new outgoing connection using a given SSL_CTX .
/* cannot fail */