perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kbr...@apache.org
Subject svn commit: r1208506 - in /perl/Apache-Test/trunk: Changes lib/Apache/TestRequest.pm
Date Wed, 30 Nov 2011 16:44:20 GMT
Author: kbrand
Date: Wed Nov 30 16:44:19 2011
New Revision: 1208506

URL: http://svn.apache.org/viewvc?rev=1208506&view=rev
Log:
Follow-up on r1207758, further improvements for SSL under LWP 6:

- do not reset the global user agent in set_client_cert()

- also set the HTTPS_CA_FILE environment variable,
  for compatibility with Net:SSL

Modified:
    perl/Apache-Test/trunk/Changes
    perl/Apache-Test/trunk/lib/Apache/TestRequest.pm

Modified: perl/Apache-Test/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/Changes?rev=1208506&r1=1208505&r2=1208506&view=diff
==============================================================================
--- perl/Apache-Test/trunk/Changes (original)
+++ perl/Apache-Test/trunk/Changes Wed Nov 30 16:44:19 2011
@@ -8,10 +8,13 @@ Changes - Apache::Test change logfile
 
 =item 1.37-dev
 
+Apache::TestRequest: improve compatibility for SSL requests with LWP 6 and
+IO::Socket::SSL, in particular [Kaspar Brand]
+
 As of httpd revision 1053230 (version 2.3.11) the NameVirtualHost directive
 became superfluous and a warning is issued when it is met. So, Apache::Test
 now wraps NameVirtualHost directives in <IfVersion> blocks.
-[Kaspar Brand <httpd-dev.2011@velox.ch>]
+[Kaspar Brand]
 
 Add comments about the source files of auto configurated tests to
 the generated httpd.conf and improve indentation a bit. [Torsten Foertsch]

Modified: perl/Apache-Test/trunk/lib/Apache/TestRequest.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestRequest.pm?rev=1208506&r1=1208505&r2=1208506&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/TestRequest.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/TestRequest.pm Wed Nov 30 16:44:19 2011
@@ -163,8 +163,10 @@ sub user_agent {
     # needs to be set accordingly
     if ($LWP::VERSION >= 6.0 and not exists $args->{ssl_opts}->{SSL_ca_file}) {
         my $vars = Apache::Test::vars();
-        $args->{ssl_opts}->{SSL_ca_file} = "$vars->{sslca}/" .
-                                           "$vars->{sslcaorg}/certs/ca.crt";
+        my $cafile = "$vars->{sslca}/$vars->{sslcaorg}/certs/ca.crt";
+        $args->{ssl_opts}->{SSL_ca_file} = $cafile;
+        # Net:SSL compatibility (legacy)
+        $ENV{HTTPS_CA_FILE} = $cafile;
     }
 
     eval { $UA ||= __PACKAGE__->new(%$args); };
@@ -626,20 +628,27 @@ sub set_client_cert {
     my $dir = join '/', $vars->{sslca}, $vars->{sslcaorg};
 
     if ($name) {
-        $ENV{HTTPS_CERT_FILE} = "$dir/certs/$name.crt";
-        $ENV{HTTPS_KEY_FILE}  = "$dir/keys/$name.pem";
+        my ($cert, $key) = ("$dir/certs/$name.crt", "$dir/keys/$name.pem");
+        @ENV{qw/HTTPS_CERT_FILE HTTPS_KEY_FILE/} = ($cert, $key);
         if ($LWP::VERSION >= 6.0) {
-            # LWP 6 no longer honors HTTPS_{CERT,KEY}_FILE
-            user_agent(reset => 1,
-                       ssl_opts => { SSL_cert_file => "$dir/certs/$name.crt",
-                                     SSL_key_file  => "$dir/keys/$name.pem" });
+            # IO::Socket:SSL doesn't look at environment variables
+            if ($UA) {
+                $UA->ssl_opts(SSL_cert_file => $cert);
+                $UA->ssl_opts(SSL_key_file  => $key);
+            } else {
+                user_agent(ssl_opts => { SSL_cert_file => $cert,
+                                         SSL_key_file  => $key });
+            }
         }
     }
     else {
         for (qw(CERT KEY)) {
             delete $ENV{"HTTPS_${_}_FILE"};
         }
-        user_agent(reset => 1) if $LWP::VERSION >= 6.0;
+        if ($LWP::VERSION >= 6.0 and $UA) {
+            $UA->ssl_opts(SSL_cert_file => undef);
+            $UA->ssl_opts(SSL_key_file  => undef);
+        }
     }
 }
 



Mime
View raw message