summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGuenter Knauf <lists@gknw.net>2014-10-23 15:18:05 +0200
committerGuenter Knauf <lists@gknw.net>2014-10-23 15:22:56 +0200
commit2be6941f423e11b73bf1bf3537585157165916db (patch)
treefb8347072c1f46cc97835b359fd33fdc336f74de /lib
parentc4f240de1424ae5d7f24a8b287856630a138e15b (diff)
downloadcurl-2be6941f423e11b73bf1bf3537585157165916db.tar.gz
Remove dependency on openssl and cut.
Prefer usage of Perl modules for sha1 calculation since there might be systems where openssl is not installed or not in path. If openssl is used for sha1 calculation then dont rely on cut since it is usually not available on other systems than Linux.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/mk-ca-bundle.pl40
1 files changed, 28 insertions, 12 deletions
diff --git a/lib/mk-ca-bundle.pl b/lib/mk-ca-bundle.pl
index 4278e8290..59e0a3254 100755
--- a/lib/mk-ca-bundle.pl
+++ b/lib/mk-ca-bundle.pl
@@ -37,6 +37,12 @@ use strict;
use vars qw($opt_b $opt_d $opt_f $opt_h $opt_i $opt_l $opt_n $opt_p $opt_q $opt_s $opt_t $opt_u $opt_v $opt_w);
use List::Util;
use Text::Wrap;
+my $MOD_SHA = "Digest::SHA";
+eval "require $MOD_SHA";
+if ($@) {
+ $MOD_SHA = "Digest::SHA::PurePerl";
+ eval "require $MOD_SHA";
+}
my %urls = (
'nss' =>
@@ -56,7 +62,7 @@ $opt_d = 'release';
# If the OpenSSL commandline is not in search path you can configure it here!
my $openssl = 'openssl';
-my $version = '1.24';
+my $version = '1.25';
$opt_w = 76; # default base64 encoded lines length
@@ -117,13 +123,15 @@ my $curl=`curl -V`;
if ($opt_i) {
print ("=" x 78 . "\n");
- print "Script Version : $version\n";
- print "Perl Version : $]\n";
- print "Operating System Name : $^O\n";
- print "Getopt::Std.pm Version : ${Getopt::Std::VERSION}\n";
- print "MIME::Base64.pm Version : ${MIME::Base64::VERSION}\n";
- print "LWP::UserAgent.pm Version : ${LWP::UserAgent::VERSION}\n";
- print "LWP.pm Version : ${LWP::VERSION}\n";
+ print "Script Version : $version\n";
+ print "Perl Version : $]\n";
+ print "Operating System Name : $^O\n";
+ print "Getopt::Std.pm Version : ${Getopt::Std::VERSION}\n";
+ print "MIME::Base64.pm Version : ${MIME::Base64::VERSION}\n";
+ print "LWP::UserAgent.pm Version : ${LWP::UserAgent::VERSION}\n";
+ print "LWP.pm Version : ${LWP::VERSION}\n";
+ print "Digest::SHA.pm Version : ${Digest::SHA::VERSION}\n" if ($Digest::SHA::VERSION);
+ print "Digest::SHA::PurePerl.pm Version : ${Digest::SHA::PurePerl::VERSION}\n" if ($Digest::SHA::PurePerl::VERSION);
print ("=" x 78 . "\n");
}
@@ -211,12 +219,20 @@ sub PARSE_CSV_PARAM($$@) {
}
sub sha1 {
- my ($txt)=@_;
- my $sha1 = `$openssl dgst -sha1 $txt | cut '-d ' -f2`;
- chomp $sha1;
- return $sha1;
+ my $result;
+ if ($Digest::SHA::VERSION || $Digest::SHA::PurePerl::VERSION) {
+ open(FILE, $_[0]) or die "Can't open '$_[0]': $!";
+ binmode(FILE);
+ $result = $MOD_SHA->new(1)->addfile(*FILE)->hexdigest;
+ close(FILE);
+ } else {
+ # Use OpenSSL command if Perl Digest::SHA modules not available
+ $result = (split(/ |\r|\n/,`$openssl dgst -sha1 $_[0]`))[1];
+ }
+ return $result;
}
+
sub oldsha1 {
my ($crt)=@_;
my $sha1="";