httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestSSLCA.pm
Date Tue, 29 Jan 2002 03:16:23 GMT
dougm       02/01/28 19:16:23

  Modified:    perl-framework/Apache-Test/lib/Apache TestSSLCA.pm
  Log:
  make it possible to override $CA/$ca_dn/$cert_dn values when generating a test CA
  
  Revision  Changes    Path
  1.8       +37 -21    httpd-test/perl-framework/Apache-Test/lib/Apache/TestSSLCA.pm
  
  Index: TestSSLCA.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSSLCA.pm,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestSSLCA.pm	29 Jan 2002 02:16:43 -0000	1.7
  +++ TestSSLCA.pm	29 Jan 2002 03:16:23 -0000	1.8
  @@ -33,7 +33,7 @@
   my $passin  = "-passin pass:$pass";
   my $passout = "-passout pass:$pass";
   
  -my %ca_dn = (
  +my $ca_dn = {
       asf => {
           C  => 'US',
           ST => 'California',
  @@ -43,9 +43,9 @@
           CN => '',
           Email => 'test-dev@httpd.apache.org',
       },
  -);
  +};
   
  -my %cert_dn = (
  +my $cert_dn = {
       client_snakeoil => {
           C  => 'AU',
           ST => 'Queensland',
  @@ -53,6 +53,10 @@
           O  => 'Snake Oil, Ltd.',
           OU => 'Staff',
       },
  +    client_ok => {
  +    },
  +    client_revoked => {
  +    },
       server => {
           CN => 'localhost',
       },
  @@ -60,18 +64,28 @@
           CN => 'localhost',
           OU => 'httpd-test/perl-framework',
       },
  -);
  +};
  +
  +sub ca_dn {
  +    $ca_dn = shift if @_;
  +    $ca_dn;
  +}
  +
  +sub cert_dn {
  +    $cert_dn = shift if @_;
  +    $cert_dn;
  +}
   
   sub dn {
       my $name = shift;
   
  -    my %dn = %{ $ca_dn{$CA} }; #default values
  +    my %dn = %{ $ca_dn->{$CA} }; #default values
       $dn{CN} ||= $name; #try make sure each Common Name is different
   
  -    my $cert_dn = $cert_dn{$name};
  +    my $default_dn = $cert_dn->{$name};
   
  -    if ($cert_dn) {
  -        while (my($key, $value) = each %$cert_dn) {
  +    if ($default_dn) {
  +        while (my($key, $value) = each %$default_dn) {
               #override values
               $dn{$key} = $value;
           }
  @@ -279,7 +293,7 @@
   sub setup {
       $CA = shift;
   
  -    unless ($ca_dn{$CA}) {
  +    unless ($ca_dn->{$CA}) {
           die "unknown CA $CA";
       }
   
  @@ -290,26 +304,28 @@
       init();
       new_ca();
   
  -    my @names = qw(server client_ok client_revoked client_snakeoil);
  +    my @names = keys %$cert_dn;
   
       for my $name (@names) {
  -        new_key($name);
  -        new_cert($name);
  -    }
  -
  -    @names = qw(server_des3);
  +        my @key_args = ();
  +        if ($name =~ /_des3$/) {
  +            push @key_args, '-des3';
  +        }
   
  -    for my $name (@names) {
  -        new_key($name, '-des3');
  +        new_key($name, @key_args);
           new_cert($name);
  -    }
   
  -    revoke_cert('client_revoked');
  +        if ($name =~ /_revoked$/) {
  +            revoke_cert($name);
  +        }
  +    }
   }
   
   sub generate {
       $Config = shift;
   
  +    $CA = shift || $Config->{vars}->{sslcaorg};
  +
       my $root = $Config->{vars}->{sslca};
   
       return if -d $root;
  @@ -327,9 +343,9 @@
   
       chdir $dir;
   
  -    warning "generating SSL CA";
  +    warning "generating SSL CA for $CA";
   
  -    setup('asf');
  +    setup($CA);
   
       chdir $pwd;
   }
  
  
  

Mime
View raw message