Authen-Credential

 view release on metacpan or  search on metacpan

lib/Authen/Credential/x509.pm  view on Meta::CPAN

        $self = shift(@_);
        validate_pos(@_) if @_;
        return($self->{$name});
    };
}

#
# preparators
#

$Authen::Credential::Preparator{x509}{"IO::Socket::SSL"} = sub {
    my($self, %data);
    $self = shift(@_);
    validate_pos(@_) if @_;
    foreach my $tmp ($self->cert(), $ENV{X509_USER_CERT}) {
        next unless defined($tmp);
        $data{SSL_cert_file} = $tmp;
        last;
    }
    foreach my $tmp ($self->key(), $ENV{X509_USER_KEY}) {
        next unless defined($tmp);

lib/Authen/Credential/x509.pm  view on Meta::CPAN

=item ca_file

the path of the file that contains the trusted certificate (optional)

=back

It supports the following targets for the prepare() method:

=over

=item IO::Socket::SSL

it returns a reference to a hash containing the suitable options for
IO::Socket::SSL

=back

=head1 EXAMPLE

  use Authen::Credential;
  use IO::Socket::SSL;

  # get the credential from somewhere
  $cred = Authen::Credential->parse(...);

  # use the prepare() method to get ready-to-use data
  $sslopts = $cred->prepare("IO::Socket::SSL");
  $socket = IO::Socket::SSL->new(
      PeerHost => "web.acme.com",
      PeerPort => "https",
      %{ $sslopts },
  );

=head1 SEE ALSO

L<Authen::Credential>,
L<IO::Socket::SSL>,
L<http://en.wikipedia.org/wiki/X.509>.

=head1 AUTHOR

Lionel Cons L<http://cern.ch/lionel.cons>

Copyright (C) CERN 2011-2015

t/1main.t  view on Meta::CPAN


$string = "HTTP.Basic";
$cred = Authen::Credential->new(
    scheme => "plain",
    name   => "system",
    pass   => "manager",
);
ok($cred, "new(plain)");
ok($cred->prepare($string), "prepare $string");

$string = "IO::Socket::SSL";
$cred = Authen::Credential->new(
    scheme => "x509",
    cert   => "/foo/cert.pem",
    key    => "/foo/key.pem",
    ca     => "/bar",
);
ok($cred, "new(x509)");
ok($cred->prepare($string), "prepare $string");

#



( run in 0.316 second using v1.01-cache-2.11-cpan-05444aca049 )