Click here to Skip to main content
15,846,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;      
ctx = SSL_CTX_new(SSLv23_client_method());     
sbio = BIO_new_ssl_connect(ctx);      
BIO_get_ssl(sbio, &ssl);          
    fprintf(stderr, "Can't locate SSL pointer\n");   
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);   
BIO_set_conn_hostname(sbio, "");//some server ip address & port    
out = BIO_new_fp(stdout, BIO_NOCLOSE);                                                
if(BIO_do_connect(sbio) <= 0)                                                              
    fprintf(stderr, "Error connecting to server\n");                                       
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
to the ip of the proxy, still not work.

hope some guys give an example , thanks.
Updated 30-Oct-18 4:41am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900