Cryptography Reference
In-Depth Information
{
int received = 0;
static char recv_buf[ BUFFER_SIZE + 1 ];
while ( SSL_get_error( ssl,
( received = SSL_read( ssl, recv_buf, BUFFER_SIZE ) ) ) ==
SSL_ERROR_NONE )
{
recv_buf[ received ] = '\0';
printf( “data: %s”, recv_buf );
}
printf( “\n” );
}
int main( int argc, char *argv[ ] )
{
int ind;
SSL_CTX *ctx;
SSL *ssl;
BIO *sbio;
BIO *bio_err=0;
SSL_METHOD *meth;
if ( argc < 2 )
{
fprintf( stderr,
“Usage: %s: [-p http://[username:password@]proxy-host:proxy-port]\
<URL>\n”, argv[ 0 ] );
return 1;
}
// OpenSSL-specific setup stuff
SSL_library_init();
SSL_load_error_strings();
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
meth=SSLv23_method();
ctx=SSL_CTX_new(meth);
proxy_host = proxy_user = proxy_password = host = path = NULL;
… // set up the connection itself
ssl=SSL_new(ctx);
sbio=BIO_new_socket(client_connection,BIO_NOCLOSE);
SSL_set_bio(ssl,sbio,sbio);
if(SSL_connect(ssl)<=0)
{
fprintf( stderr, “Error: unable to negotiate SSL connection.\n” );
if ( close( client_connection ) == -1 )
{
(Continued)
Search WWH ::




Custom Search