summaryrefslogtreecommitdiff
path: root/lib/mk-ca-bundle.pl
diff options
context:
space:
mode:
authorGuenter Knauf <lists@gknw.net>2014-10-23 16:27:40 +0200
committerGuenter Knauf <lists@gknw.net>2014-10-23 16:27:40 +0200
commit4b7d499e6414870c49b5fdba6922fb80b25ecc93 (patch)
tree7f4c831d65b90d34f453107fb45bf68295fe6d19 /lib/mk-ca-bundle.pl
parent2be6941f423e11b73bf1bf3537585157165916db (diff)
downloadcurl-4b7d499e6414870c49b5fdba6922fb80b25ecc93.tar.gz
Some cosmetics and simplifies.
Diffstat (limited to 'lib/mk-ca-bundle.pl')
-rwxr-xr-xlib/mk-ca-bundle.pl51
1 files changed, 21 insertions, 30 deletions
diff --git a/lib/mk-ca-bundle.pl b/lib/mk-ca-bundle.pl
index 59e0a3254..58c49fdee 100755
--- a/lib/mk-ca-bundle.pl
+++ b/lib/mk-ca-bundle.pl
@@ -234,18 +234,17 @@ sub sha1 {
sub oldsha1 {
- my ($crt)=@_;
- my $sha1="";
- open(C, "<$crt") || return 0;
- while(<C>) {
- chomp;
- if($_ =~ /^\#\# SHA1: (.*)/) {
- $sha1 = $1;
- last;
- }
+ my $sha1 = "";
+ open(C, "<$_[0]") || return 0;
+ while(<C>) {
+ chomp;
+ if($_ =~ /^\#\# SHA1: (.*)/) {
+ $sha1 = $1;
+ last;
}
- close(C);
- return $sha1;
+ }
+ close(C);
+ return $sha1;
}
if ( $opt_p !~ m/:/ ) {
@@ -277,31 +276,23 @@ my $stdout = $crt eq '-';
my $resp;
my $fetched;
-my $oldsha1= oldsha1($crt);
+my $oldsha1 = oldsha1($crt);
print STDERR "SHA1 of old file: $oldsha1\n" if (!$opt_q);
print STDERR "Downloading '$txt' ...\n" if (!$opt_q);
if($curl && !$opt_n) {
- my $https = $url;
- $https =~ s/^http:/https:/;
- printf "Get certdata over HTTPS with curl!\n", $https;
- my $quiet = $opt_q?"-s":"";
- my @out = `curl -w %{response_code} $quiet -O $https`;
-
- my $code = 0;
- if(@out) {
- $code = $out[0];
- }
-
- if($code == 200) {
- $fetched = 1;
- }
- else {
- print STDERR "Failed downloading HTTPS with curl, trying HTTP with LWP\n"
- unless $opt_q;
- }
+ my $https = $url;
+ $https =~ s/^http:/https:/;
+ print STDERR "Get certdata over HTTPS with curl!\n" if (!$opt_q);
+ my $quiet = $opt_q ? "-s" : "";
+ my @out = `curl -w %{response_code} $quiet -O $https`;
+ if(@out && $out[0] == 200) {
+ $fetched = 1;
+ } else {
+ print STDERR "Failed downloading HTTPS with curl, trying HTTP with LWP\n" if (!$opt_q);
+ }
}
unless ($fetched || ($opt_n and -e $txt)) {