modperl-verifying_whether_a_request_was_received_over_an_ssl_connection

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Reif Peter <gal@adv.magwien.gv.at>
From: Stas Bekman <stas@stason.org>
Subject: Re: http or https in URL?
Date: Tue, 06 Nov 2001 23:45:03 +0800

Reif Peter wrote:

> In a mod_perl handler I want to construct the original URL of the request. I
> can construct it with r->get_server_name, r->get_server_port, r->uri and
> $r->parsed_uri->query.
> 
> But how do I get the protocol, http or https.  Is there a way to find out
> whether SSLEngine On is set?
> 
> Yes, I can set it with "PerlSetVar protocol https", but is there a simpler
> way?


There was a long related discussion a few weeks ago. Here is what I've 
added to the guide (not online yet):


=head1 Verifying Whether A Request Was Received Over An SSL Connection

Just like C<$ENV{MODPERL}> is checked to see whether the code is run
under mod_perl, C<$ENV{HTTPS}> is set by ssl modules and therefore can
be used to check whether a request is running over SSL connection. For
example:

   print "SSL" if $ENV{HTTPS};

If C<PerlSetupEnv Off> setting is in effect, C<$ENV{HTTPS}> won't be
available, and then:

   print "SSL" if $r->subprocess_env('https');

should be used instead.

Note that it's also possible to check the scheme:

   print "SSL" if Apache::URI->parse($r)->scheme =~ m/^https/;

but it's not one hundred percent certain unless you control the server
and you know that you run a secure server on the port 443.

===

To: modperl@apache.org
From: Reif Peter <gal@adv.magwien.gv.at>
Subject: RE: http or https in URL?
Date: Wed, 7 Nov 2001 10:23:49 +0100 

> From: Stas Bekman *EXTERN* [mailto:stas@stason.org]
> 
> Reif Peter wrote:
> 
> > In a mod_perl handler I want to construct the original URL 
> of the request. I
> > can construct it with r->get_server_name, 
> r->get_server_port, r->uri and
> > $r->parsed_uri->query.
> > 
> > But how do I get the protocol, http or https.  Is there a 
> way to find out
> > whether SSLEngine On is set?
> > 
> 
> 
> Note that it's also possible to check the scheme:
> 
>    print "SSL" if Apache::URI->parse($r)->scheme =~ m/^https/;
> 
scheme is good!
Why is $r->parsed_uri not the same as Apache::URI->parse($r) ?

Another question: If my server listens to 2 adresses as with
<VirtualHost _default_:443 _default_:4443>
I get always 443 from s->port. The REAL port I get from the Host header. Is
there another way?

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu