mirror of
https://github.com/moparisthebest/curl
synced 2025-03-11 07:39:50 -04:00
mk-ca-bundle.pl: Only download if modified
Only download and convert the certdata to the ca-bundle.crt if Mozilla changed the data The Perl LWP module (which in a bit of a circular reference is used by mk-ca-bundle.pl) is now indirectly using this script. I made this small tweak to make it easier to automatically maintain the generated ca-bundle.crt file in version control.
This commit is contained in:
parent
3eac14b43c
commit
3e00af34c8
@ -75,20 +75,22 @@ my $crt = $ARGV[0] || 'ca-bundle.crt';
|
|||||||
my $txt = substr($url, rindex($url, '/') + 1);
|
my $txt = substr($url, rindex($url, '/') + 1);
|
||||||
$txt =~ s/\?.*//;
|
$txt =~ s/\?.*//;
|
||||||
|
|
||||||
if (!$opt_n || !-e $txt) {
|
my $resp;
|
||||||
|
|
||||||
|
unless ($opt_n and -e $txt) {
|
||||||
print "Downloading '$txt' ...\n" if (!$opt_q);
|
print "Downloading '$txt' ...\n" if (!$opt_q);
|
||||||
|
|
||||||
my $ua = new LWP::UserAgent(agent => "$0/$version");
|
my $ua = new LWP::UserAgent(agent => "$0/$version");
|
||||||
my $req = new HTTP::Request('GET', $url);
|
$resp = $ua->mirror($url, 'certdata.txt');
|
||||||
my $res = $ua->request($req);
|
|
||||||
if ($res->is_success) {
|
|
||||||
open(TXT,">$txt") or die "Couldn't open $txt: $!";
|
|
||||||
print TXT $res->content . "\n";
|
|
||||||
close(TXT) or die "Couldn't close $txt: $!";
|
|
||||||
} else {
|
|
||||||
die $res->status_line;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($resp && $resp->code eq '304') {
|
||||||
|
print "Not modified\n" unless $opt_q;
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $currentdate = scalar gmtime($resp ? $resp->last_modified : (stat($txt))[9]);
|
||||||
|
|
||||||
if ($opt_b && -e $crt) {
|
if ($opt_b && -e $crt) {
|
||||||
my $bk = 1;
|
my $bk = 1;
|
||||||
while (-e "$crt.~${bk}~") {
|
while (-e "$crt.~${bk}~") {
|
||||||
@ -98,13 +100,12 @@ if ($opt_b && -e $crt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $format = $opt_t ? "plain text and " : "";
|
my $format = $opt_t ? "plain text and " : "";
|
||||||
my $currentdate = scalar gmtime() . " UTC";
|
|
||||||
open(CRT,">$crt") or die "Couldn't open $crt: $!";
|
open(CRT,">$crt") or die "Couldn't open $crt: $!";
|
||||||
print CRT <<EOT;
|
print CRT <<EOT;
|
||||||
##
|
##
|
||||||
## $crt -- Bundle of CA Root Certificates
|
## $crt -- Bundle of CA Root Certificates
|
||||||
##
|
##
|
||||||
## Converted at: ${currentdate}
|
## Certificate data from Mozilla as of: ${currentdate}
|
||||||
##
|
##
|
||||||
## This is a bundle of X.509 certificates of public Certificate Authorities
|
## This is a bundle of X.509 certificates of public Certificate Authorities
|
||||||
## (CA). These were automatically extracted from Mozilla's root certificates
|
## (CA). These were automatically extracted from Mozilla's root certificates
|
||||||
|
Loading…
x
Reference in New Issue
Block a user