diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-04-01 08:57:28 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-04-01 08:58:05 +0200 |
commit | 10a8d44e07504176be9e5a583128b09271b4dcf9 (patch) | |
tree | 38a9c4cb32d4f91d40cc69a420eae884c00b6db3 | |
parent | b535ec32984f37a0d88c8822e352d95075cabe50 (diff) | |
download | acmeman-10a8d44e07504176be9e5a583128b09271b4dcf9.tar.gz acmeman-10a8d44e07504176be9e5a583128b09271b4dcf9.tar.bz2 |
Use LWP::UserAgent instead of WWW::Curl::Easy
-rw-r--r-- | Makefile.PL | 3 | ||||
-rwxr-xr-x | acmeman | 29 |
2 files changed, 14 insertions, 18 deletions
diff --git a/Makefile.PL b/Makefile.PL index bfa834a..1798216 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,7 +13,8 @@ use ExtUtils::AutoInstall ( 'Crypt::OpenSSL::RSA' => 0.28, 'Crypt::OpenSSL::X509' => 1.807, 'DateTime::Format::Strptime' => 1.42, - 'WWW::Curl::Easy' => 4.17, + 'LWP::UserAgent' => 6.15, + 'LWP::Protocol::https' => 6.07, 'Pod::Usage' => 1.51, 'Pod::Man' => 2.25, 'Data::Dumper' => 0 @@ -24,14 +24,15 @@ use Crypt::OpenSSL::X509; use File::Basename; use File::Path qw(make_path); use DateTime::Format::Strptime; -use WWW::Curl::Easy; +use LWP::UserAgent; +use LWP::Protocol::https; use Pod::Usage; use Pod::Man; use Getopt::Long qw(:config gnu_getopt no_ignore_case); use POSIX qw(strftime time floor); use Data::Dumper; -our $VERSION = '1.01'; +our $VERSION = '1.02'; =head1 NAME @@ -707,23 +708,17 @@ sub get_root_cert { prep_dir($name); debug(1, "downloading $letsencrypt_root_cert_url to \"$name\""); - open(my $fd, '>', $name) - or abend(EX_CANTCREAT, "can't open \"$name\" for writing: $!"); - my $curl = WWW::Curl::Easy->new; - $curl->setopt(CURLOPT_HEADER,0); - $curl->setopt(CURLOPT_URL, $letsencrypt_root_cert_url); - $curl->setopt(CURLOPT_WRITEDATA, $fd); - my $rc = $curl->perform; - my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); - if ($rc) { - error("error downloading certificate from $letsencrypt_root_cert_url"); - error($curl->errbuf); - abend(EX_NOINPUT, $curl->strerror($rc)); - } elsif ($response_code != 200) { + my $ua = LWP::UserAgent->new; + my $response = $ua->get($letsencrypt_root_cert_url); + if ($response->is_success) { + open(my $fd, '>', $name) + or abend(EX_CANTCREAT, "can't open \"$name\" for writing: $!"); + print $fd $response->decoded_content; + close $fd; + } else { error("error downloading certificate from $letsencrypt_root_cert_url"); - abend(EX_NOINPUT, "unexpected response code: $response_code"); + abend(EX_NOINPUT, $response->status_line); } - close $fd; } sub initial_setup { |