perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kbr...@apache.org
Subject svn commit: r1207758 - /perl/Apache-Test/trunk/lib/Apache/TestRequest.pm
Date Tue, 29 Nov 2011 05:39:37 GMT
Author: kbrand
Date: Tue Nov 29 05:39:36 2011
New Revision: 1207758

URL: http://svn.apache.org/viewvc?rev=1207758&view=rev
Log:
Compatibility fixes for SSL requests under LWP 6:

- set SSL_ca_file in user_agent(), if not yet set
  (needed for successful verification when verify_hostname is enabled)

- in set_client_cert(), also set the cert via LWP::UserAgent's new ssl_opts

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

Modified: perl/Apache-Test/trunk/lib/Apache/TestRequest.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestRequest.pm?rev=1207758&r1=1207757&r2=1207758&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/TestRequest.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/TestRequest.pm Tue Nov 29 05:39:36 2011
@@ -159,6 +159,14 @@ sub user_agent {
         };
     }
 
+    # in LWP 6, verify_hostname defaults to on, so SSL_ca_file
+    # 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";
+    }
+
     eval { $UA ||= __PACKAGE__->new(%$args); };
 }
 
@@ -352,7 +360,7 @@ sub prepare {
         }
         push @$pass, content => $content;
     }
-    if ($keep->{cert}) {
+    if (exists $keep->{cert}) {
         set_client_cert($keep->{cert});
     }
 
@@ -620,11 +628,18 @@ sub set_client_cert {
     if ($name) {
         $ENV{HTTPS_CERT_FILE} = "$dir/certs/$name.crt";
         $ENV{HTTPS_KEY_FILE}  = "$dir/keys/$name.pem";
+        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" });
+        }
     }
     else {
         for (qw(CERT KEY)) {
             delete $ENV{"HTTPS_${_}_FILE"};
         }
+        user_agent(reset => 1) if $LWP::VERSION >= 6.0;
     }
 }
 



Mime
View raw message