Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Think about Loose Coupling
 
PerlMonks  

Re: HTTP::Daemon and SSL

by rob_au (Abbot)
on Jul 07, 2002 at 07:23 UTC ( #179945=note: print w/ replies, xml ) Need Help??


in reply to HTTP::Daemon and SSL

Okay, while I may not be able to give you a complete solution with tested code, I should be able to help you out, having worked on a similar project previously.

The CONNECT method which you are receiving from HTTP clients is documented in RFC2616, as the means by which SSL connections are tunneled through HTTP connections. This method is sent by a HTTP client to a proxy server, followed by the destination host and destination port number - For example:

CONNECT ssl.webserver.com:443 HTTP/1.0

At this point, the HTTP proxy should initiate a connection to the designated port on the destination host and, if successful, return a 200 HTTP success code. The secure communication can then take place over the established connection.

With regard to making all this happen in your code, there is a patch available for the HTTP::Daemon module within the IO::Socket::SSL module which changes the inheritance of HTTP::Daemon to make use of IO::Socket::SSL in place of IO::Socket. Also too, if you have no luck with this, there are a couple of other patches for HTTP::Daemon which I can seen that are designed to achieve your goal and can also post these if required.

From IO-Socket-SSL-0.81\diffs\libwww-perl\HTTP_Daemon.pm.diff ...

*** /usr/local/perl5.005_03/lib/site_perl/5.005/HTTP/Daemon.pm.orig + Wed Jun 9 19:41:53 1999 --- /usr/local/perl5.005_03/lib/site_perl/5.005/HTTP/Daemon.pm Wed +Jun 9 19:42:43 1999 *************** *** 63,69 **** $VERSION = sprintf("%d.%02d", q$Revision: 1.21 $ =~ /(\d+)\.(\d+)/); use IO::Socket (); ! @ISA=qw(IO::Socket::INET); $PROTO = "HTTP/1.1"; --- 63,71 ---- $VERSION = sprintf("%d.%02d", q$Revision: 1.21 $ =~ /(\d+)\.(\d+)/); use IO::Socket (); ! use IO::Socket::SSL; ! #@ISA=qw(IO::Socket::INET); ! @ISA=qw(IO::Socket::SSL); $PROTO = "HTTP/1.1"; *************** *** 156,162 **** use vars qw(@ISA $DEBUG); use IO::Socket (); ! @ISA=qw(IO::Socket::INET); *DEBUG = \$HTTP::Daemon::DEBUG; use HTTP::Request (); --- 158,165 ---- use vars qw(@ISA $DEBUG); use IO::Socket (); ! #@ISA=qw(IO::Socket::INET); ! @ISA=qw(IO::Socket::SSL); *DEBUG = \$HTTP::Daemon::DEBUG; use HTTP::Request ();

Also see the demo file from the IO::Socket::SSL distribution, IO-Socket-SSL-0.81\demo\daemon.pl, which makes use of HTTP::Daemon in this fashion.

Good luck!

 


Comment on Re: HTTP::Daemon and SSL
Select or Download Code
Re: Re: HTTP::Daemon and SSL
by niemeand (Initiate) on Nov 24, 2002 at 15:39 UTC
    Hello. I've tried your hints by doing the changes of Daemon.pm and use my script but not with desired success. Has anyone perhaps sample-code for proxying client-requests with CONNECT-method to establish ssl and what additional changes have to do? I'll be very glad, if someone can post it here. Best regards, Andreas
    my $UA = LWP::UserAgent->new; $UA->agent("Mozilla/4.0"); $UA->protocols_allowed(['http','https']); my $SRV = HTTP::Daemon->new(LocalPort => 3128); while (my $conn = $SRV->accept) { while (my $request = $conn->get_request) { my $resp = $UA->simple_request($request); $conn->send_response($resp); } $conn->close; }
    Debugoutput in request to local webserver and https://www.nodeworks.com looks like:
    LWP::UserAgent::send_request: GET http://127.0.0.1/ LWP::UserAgent::_need_proxy: Not proxied LWP::UserAgent::send_request: http URLs are among LWP::UserAgent=HASH( +0x1fe594)'s allowed protocols (http https) LWP::Protocol::http::request: () LWP::Protocol::collect: read 639 bytes LWP::Protocol::collect: read 817 bytes LWP::UserAgent::send_request: GET http://127.0.0.1/apache_pb.gif LWP::UserAgent::_need_proxy: Not proxied LWP::UserAgent::send_request: http URLs are among LWP::UserAgent=HASH( +0x1fe594)'s allowed protocols (http https) LWP::Protocol::http::request: () LWP::UserAgent::send_request: CONNECT http://www.nodeworks.com:443 LWP::UserAgent::_need_proxy: Not proxied LWP::UserAgent::send_request: http URLs are among LWP::UserAgent=HASH( +0x1fe594)'s allowed protocols (http https) LWP::Protocol::http::request: () LWP::UserAgent::send_request: CONNECT http://www.nodeworks.com:443 LWP::UserAgent::_need_proxy: Not proxied LWP::UserAgent::send_request: http URLs are among LWP::UserAgent=HASH( +0x1fe594)'s allowed protocols (http https) LWP::Protocol::http::request: ()

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://179945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (19)
As of 2014-04-17 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls