Changeset 10463 for lang/perl/Punc

Show
Ignore:
Timestamp:
04/25/08 23:49:01 (7 months ago)
Author:
mizzy
Message:

SSLクライアント認証に対応した。これで同一のCAから発行された証明書を提示したリクエストのみ、puncdは処理をする。

Location:
lang/perl/Punc/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Punc/trunk/Makefile.PL

    r10104 r10463  
    1818                       Pod::Usage 
    1919                       File::Path 
     20                       Crypt::SSLeay 
    2021                   /); 
    2122 
  • lang/perl/Punc/trunk/bin/punc

    r10103 r10463  
    1616 
    1717for (@$res) { 
    18     if ( $method eq 'description' ) { 
     18    if ( $method eq 'description' || $method eq 'desc' ) { 
    1919        print $_->{response}->{result}; 
    2020    } 
  • lang/perl/Punc/trunk/lib/Punc/Client.pm

    r8509 r10463  
    77use Punc::Client::Request; 
    88use UNIVERSAL::require; 
     9use FindBin; 
    910 
    1011sub new { 
    1112    my ( $class, $target ) = @_; 
    1213 
     14    ### TODO: confdir のデフォルト値を変更 
    1315    ## TODO: $target から対象ホストをリストアップ 
    1416 
    15     bless { hosts => [ $target ] }, $class; 
     17    bless { 
     18        hosts   => [ $target ], 
     19        confdir => "$FindBin::Bin/../etc", 
     20    }, $class; 
    1621} 
    1722 
     
    2328 
    2429    return Punc::Client::Request->new({ 
    25         hosts  => $self->{hosts}, 
    26         module => $module, 
     30        confdir => $self->{confdir}, 
     31        hosts   => $self->{hosts}, 
     32        module  => $module, 
    2733    }); 
    2834} 
  • lang/perl/Punc/trunk/lib/Punc/Client/Request.pm

    r10103 r10463  
    66use JSON::RPC::Client; 
    77use Punc::Client::Response; 
     8use File::Spec; 
     9 
    810our $AUTOLOAD; 
    911 
    1012sub new { 
    1113    my ( $class, $args ) = @_; 
     14 
     15    $ENV{HTTPS_VERSION}   = 3; 
     16    $ENV{HTTPS_CERT_FILE} = File::Spec->catfile( 
     17        $args->{confdir}, 'ssl', 'ca', 'ca.cert' 
     18    ); 
     19    $ENV{HTTPS_KEY_FILE}  = File::Spec->catfile( 
     20        $args->{confdir}, 'ssl', 'ca', 'ca.key' 
     21    ); 
     22 
     23    $args->{client} = JSON::RPC::Client->new; 
     24 
    1225    bless $args, $class; 
    1326} 
     
    1831    my $response = Punc::Client::Response->new; 
    1932    for my $host ( @{ $self->{hosts} } ) { 
    20         my $client = new JSON::RPC::Client; 
     33 
    2134        my $url    = "https://$host:7080/$self->{module}"; 
    2235        my $callobj = { 
     
    2538        }; 
    2639 
    27         my $res = $client->call($url, $callobj); 
     40        my $res = $self->{client}->call($url, $callobj); 
    2841 
    2942        if( $res ) { 
  • lang/perl/Punc/trunk/lib/Punc/Daemon.pm

    r10154 r10463  
    2121sub run { 
    2222    my $self = shift; 
     23 
     24    my $ssl_verify_mode = ref $self eq 'Punc::Master::Daemon' ? 0x00 : 0x07; 
     25 
    2326    my $d = HTTP::Daemon::SSL->new( 
    24         LocalPort      => $self->{port}, 
    25         ReuseAddr      => 1, 
    26         SSL_key_file   => $self->{ssl_key}, 
    27         SSL_cert_file  => $self->{ssl_cert}, 
    28         SSL_ca_file    => $self->{ca_cert} || '', 
     27        LocalPort       => $self->{port}, 
     28        ReuseAddr       => 1, 
     29        SSL_key_file    => $self->{ssl_key}, 
     30        SSL_cert_file   => $self->{ssl_cert}, 
     31        SSL_ca_file     => $self->{ca_cert} || '', 
     32        SSL_verify_mode => $ssl_verify_mode, 
    2933    ) || die $!; 
    3034 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Daemon.pm

    r10154 r10463  
    2222    $self->{ssl_cert} = File::Spec->catfile($self->{certdir}, "${fqdn}.cert"); 
    2323    $self->{ca_cert}  = File::Spec->catfile($self->{certdir}, 'ca.cert'); 
    24  
    2524    return $self; 
    2625} 
     
    9796 
    9897    my $res; 
    99     if ( $method eq 'description' ) { 
     98    if ( $method eq 'description' || $method eq 'desc' ) { 
    10099        $res = $module->description; 
    101100    } 
  • lang/perl/Punc/trunk/lib/Punc/Slave/Module/Service/RedHat.pm

    r8565 r10463  
    55use base qw( Punc::Slave::Module::Service ); 
    66 
     7### TODO: もっと簡単に定義できないか考える 
     8### default_for { operatingsystem => [ qw/ redhat fedora centos / ] } とか 
     9### use Punc::Slave::Module::Service { operatingsystem => [ qw / fedora / ] } とか 
    710sub default_for { 
    811    return { 'operatingsystem' => [ 'redhat', 'fedora', 'centos' ] }