--- openssl-1.0.0e_bkp/apps/s_client.c 2009-12-16 20:28:28.000000000 +0000 +++ openssl-1.0.0e/apps/s_client.c 2011-11-30 10:14:55.021397000 +0000 @@ -390,6 +390,7 @@ int sbuf_len,sbuf_off; fd_set readfds,writefds; short port=PORT; + char *http_proxy_str=NULL, *connect_str=NULL; int full_log=1; char *host=SSL_HOST_NAME; char *cert_file=NULL,*key_file=NULL; @@ -492,11 +493,15 @@ if (port == 0) goto bad; } else if (strcmp(*argv,"-connect") == 0) - { - if (--argc < 1) goto bad; - if (!extract_host_port(*(++argv),&host,NULL,&port)) - goto bad; - } + { + if (--argc < 1) goto bad; + connect_str = *(++argv); + } + else if (strcmp(*argv,"-http_proxy") == 0) + { + if (--argc < 1) goto bad; + http_proxy_str = *(++argv); + } else if (strcmp(*argv,"-verify") == 0) { verify=SSL_VERIFY_PEER; @@ -732,6 +737,18 @@ argc--; argv++; } + + if (http_proxy_str) + { + if (!extract_host_port(http_proxy_str,&host,NULL,&port)) + goto bad; + } + else + { + if (!extract_host_port(connect_str,&host,NULL,&port)) + goto bad; + } + if (badop) { bad: @@ -1200,6 +1217,28 @@ goto shut; mbuf[0] = 0; } + if (http_proxy_str) + { + int foundit=0; + BIO *fbio = BIO_new(BIO_f_buffer()); + BIO_push(fbio, sbio); + BIO_printf(fbio,"CONNECT %s\r\n\r\n", connect_str); + (void)BIO_flush(fbio); + /* wait for multi-line response to end CONNECT response */ + do + { + mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ); + if (strstr(mbuf,"200") && + strstr(mbuf,"established")) + foundit++; + } + while (mbuf_len>3 && foundit == 0); + (void)BIO_flush(fbio); + BIO_pop(fbio); + BIO_free(fbio); + if (!foundit) + BIO_printf(bio_err, "HTTP CONNECT failed\n"); + } for (;;) { --- openssl-1.0.0e_bkp/doc/apps/s_client.pod 2009-06-26 11:28:51.000000000 +0000 +++ openssl-1.0.0e/doc/apps/s_client.pod 2011-11-30 10:10:36.186904000 +0000 @@ -37,6 +37,7 @@ [B<-bugs>] [B<-cipher cipherlist>] [B<-starttls protocol>] +[B<-proxy host:port>] [B<-engine id>] [B<-tlsextdebug>] [B<-no_ticket>] @@ -205,6 +206,12 @@ B is a keyword for the intended protocol. Currently, the only supported keywords are "smtp", "pop3", "imap", and "ftp". +=item B<-http_proxy host:port> + +connect over HTTP proxy. "host:port" of -http_proxy option is used for the +TCP connect to the proxy and the HTTP CONNECT command is called with +"host:port" of the -connect option. + =item B<-tlsextdebug> print out a hex dump of any TLS extensions received from the server.