Click here to Skip to main content
14,427,747 members

Openssl lib and proxy

Yount_0701 asked:

Open original thread
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.
Tags: C, HTTP, SSL, proxy, OpenSSL


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100