Hello everyone! I'm trying to use openssl lib to access some web and analyse the http json response.the earlier test is ok until it send http request through a http proxy.
i'm not familiar with this lib, which sounds very powerful. and i'm sure that the proxy problem should be considered by the lib dev. there are very limited resource about this lib i could found.Is there any method to set the parameters or some initial functions to do with this?
What I have tried:
this is some simple code which works well without proxy. how to change the code and support the proxy ?
BIO *sbio, *out;
int len;
char tmpbuf[1024];
SSL_CTX *ctx;
SSL *ssl;
ERR_load_SSL_strings();
SSL_library_init();
ctx = SSL_CTX_new(SSLv23_client_method());
sbio = BIO_new_ssl_connect(ctx);
BIO_get_ssl(sbio, &ssl);
if(!ssl)
{
fprintf(stderr, "Can't locate SSL pointer\n");
ERR_print_errors_fp(stderr);
}
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
BIO_set_conn_hostname(sbio, "106.39.167.232:443");
out = BIO_new_fp(stdout, BIO_NOCLOSE);
if(BIO_do_connect(sbio) <= 0)
{
fprintf(stderr, "Error connecting to server\n");
ERR_print_errors_fp(stderr);
}
printf("SSL connection using %s\n",SSL_get_cipher(ssl));
...
there are also some messages after the demo execution
Error connecting to server
2601232:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl\record\ssl3_record.c:252:
I've tried to change the paramater of
BIO_set_conn_hostname
to the ip of the proxy, still not work.
hope some guys give an example , thanks.