NAME

OpenStack::MetaAPI::UserAgent - an LWP::UserAgent that leaves TLS hostname verification to LWP

VERSION

version 0.005

SYNOPSIS

my $endpoint  = $ENV{OS_AUTH_URL};
my %auth_args = (
    username => $ENV{OS_USERNAME},
    password => $ENV{OS_PASSWORD},
);

# OpenStack::MetaAPI uses this class unless you name another one.
my $api = OpenStack::MetaAPI->new($endpoint, %auth_args);

# An auth object that you build yourself has to be given it.
my $auth = OpenStack::Client::Auth->new(
    $endpoint, %auth_args,
    package_ua => 'OpenStack::MetaAPI::UserAgent',
);
my $api_from_auth = OpenStack::MetaAPI->new({auth => $auth});

DESCRIPTION

OpenStack::Client makes each of its user agents with

ssl_opts => { verify_hostname => 0 }

and no argument changes that. So without this class, every request goes to whichever server answers for the endpoint, with the X-Auth-Token of the session in its headers.

This class removes verify_hostname from the ssl_opts it is given, and passes everything else to LWP::UserAgent. LWP then decides, as it does for any user agent: the check is on, unless the environment variable PERL_LWP_SSL_VERIFY_HOSTNAME is set to 0. If PERL_LWP_SSL_VERIFY_HOSTNAME is not set, the older variables HTTPS_CA_FILE and HTTPS_CA_DIR also turn the check off, for compatibility with Crypt::SSLeay. To trust a private certificate authority, set PERL_LWP_SSL_CA_FILE or PERL_LWP_SSL_CA_PATH. To change anything else, subclass this class and give yours as package_ua.

METHODS

new( %opts )

Returns a new user agent, as "new" in LWP::UserAgent does, from %opts with verify_hostname taken out of ssl_opts.

AUTHOR

Nicolas R <atoomic@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 by cPanel, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.