master
1#!/usr/bin/env perl
2# ***************************************************************************
3# * _ _ ____ _
4# * Project ___| | | | _ \| |
5# * / __| | | | |_) | |
6# * | (__| |_| | _ <| |___
7# * \___|\___/|_| \_\_____|
8# *
9# * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10# *
11# * This software is licensed as described in the file COPYING, which
12# * you should have received as part of this distribution. The terms
13# * are also available at https://curl.se/docs/copyright.html.
14# *
15# * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# * copies of the Software, and permit persons to whom the Software is
17# * furnished to do so, under the terms of the COPYING file.
18# *
19# * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# * KIND, either express or implied.
21# *
22# * SPDX-License-Identifier: curl
23# *
24# ***************************************************************************
25# This Perl script creates a fresh ca-bundle.crt file for use with libcurl.
26# It downloads certdata.txt from Mozilla's source tree (see URL below),
27# then parses certdata.txt and extracts CA Root Certificates into PEM format.
28# These are then processed with the OpenSSL commandline tool to produce the
29# final ca-bundle.crt file.
30# The script is based on the parse-certs script written by Roland Krikava.
31# This Perl script works on almost any platform since its only external
32# dependency is the OpenSSL commandline tool for optional text listing.
33# Hacked by Guenter Knauf.
34#
35use Encode;
36use Getopt::Std;
37use MIME::Base64;
38use strict;
39use warnings;
40use vars qw($opt_b $opt_d $opt_f $opt_h $opt_i $opt_k $opt_l $opt_m $opt_n $opt_p $opt_q $opt_s $opt_t $opt_u $opt_v $opt_w $opt_x);
41use List::Util;
42use Text::Wrap;
43use Time::Local;
44my $MOD_SHA = "Digest::SHA";
45eval "require $MOD_SHA";
46if($@) {
47 $MOD_SHA = "Digest::SHA::PurePerl";
48 eval "require $MOD_SHA";
49}
50eval "require LWP::UserAgent";
52my %urls = (
53 'autoland' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/autoland/security/nss/lib/ckfw/builtins/certdata.txt',
54 'beta' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/beta/security/nss/lib/ckfw/builtins/certdata.txt',
55 'nss' => 'https://raw.githubusercontent.com/mozilla/nss/refs/heads/master/lib/ckfw/builtins/certdata.txt',
56 'release' => 'https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/release/security/nss/lib/ckfw/builtins/certdata.txt',
57);
59$opt_d = 'release';
61# If the OpenSSL commandline is not in search path you can configure it here!
62my $openssl = 'openssl';
64my $version = '1.35';
66$opt_w = 76; # default base64 encoded lines length
68# default cert types to include in the output (default is to include CAs which
69# may issue SSL server certs)
70my $default_mozilla_trust_purposes = "SERVER_AUTH";
71my $default_mozilla_trust_levels = "TRUSTED_DELEGATOR";
72$opt_p = $default_mozilla_trust_purposes . ":" . $default_mozilla_trust_levels;
74my @valid_mozilla_trust_purposes = (
75 "DIGITAL_SIGNATURE",
76 "NON_REPUDIATION",
77 "KEY_ENCIPHERMENT",
78 "DATA_ENCIPHERMENT",
79 "KEY_AGREEMENT",
80 "KEY_CERT_SIGN",
81 "CRL_SIGN",
82 "SERVER_AUTH",
83 "CLIENT_AUTH",
84 "CODE_SIGNING",
85 "EMAIL_PROTECTION",
86 "IPSEC_END_SYSTEM",
87 "IPSEC_TUNNEL",
88 "IPSEC_USER",
89 "TIME_STAMPING",
90 "STEP_UP_APPROVED"
91);
93my @valid_mozilla_trust_levels = (
94 "TRUSTED_DELEGATOR", # CAs
95 "NOT_TRUSTED", # Do not trust these certs.
96 "MUST_VERIFY_TRUST", # This explicitly tells us that it IS NOT a CA but is
97 # otherwise ok. In other words, this should tell the
98 # app to ignore any other sources that claim this is
99 # a CA.
100 "TRUSTED" # This cert is trusted, but only for itself and not
101 # for delegates (i.e. it is not a CA).
102);
104my $default_signature_algorithms = $opt_s = "SHA256";
106my @valid_signature_algorithms = (
107 "SHA256",
108 "SHA384",
109 "SHA512"
110);
112$0 =~ s@.*(/|\\)@@;
113$Getopt::Std::STANDARD_HELP_VERSION = 1;
114getopts('bd:fhiklmnp:qs:tuvw:x:');
116if(!defined($opt_d)) {
117 # to make plain "-d" use not cause warnings, and actually still work
118 $opt_d = 'release';
119}
121# Use predefined URL or else custom URL specified on command line.
122my $url;
123if(defined($urls{$opt_d})) {
124 $url = $urls{$opt_d};
125 if(!$opt_k && $url !~ /^https:\/\//i) {
126 die "The URL for '$opt_d' is not HTTPS. Use -k to override (insecure).\n";
127 }
128}
129else {
130 $url = $opt_d;
131}
133if($opt_i) {
134 print ("=" x 78 . "\n");
135 print "Script Version : $version\n";
136 print "Perl Version : $]\n";
137 print "Operating System Name : $^O\n";
138 print "Getopt::Std.pm Version : ${Getopt::Std::VERSION}\n";
139 print "Encode::Encoding.pm Version : ${Encode::Encoding::VERSION}\n";
140 print "MIME::Base64.pm Version : ${MIME::Base64::VERSION}\n";
141 print "LWP::UserAgent.pm Version : ${LWP::UserAgent::VERSION}\n" if($LWP::UserAgent::VERSION);
142 print "LWP.pm Version : ${LWP::VERSION}\n" if($LWP::VERSION);
143 print "Digest::SHA.pm Version : ${Digest::SHA::VERSION}\n" if($Digest::SHA::VERSION);
144 print "Digest::SHA::PurePerl.pm Version : ${Digest::SHA::PurePerl::VERSION}\n" if($Digest::SHA::PurePerl::VERSION);
145 print ("=" x 78 . "\n");
146}
148sub warning_message() {
149 if($opt_d =~ m/^risk$/i) { # Long Form Warning and Exit
150 print "Warning: Use of this script may pose some risk:\n";
151 print "\n";
152 print " 1. If you use HTTP URLs they are subject to a man in the middle attack\n";
153 print " 2. Default to 'release', but more recent updates may be found in other trees\n";
154 print " 3. certdata.txt file format may change, lag time to update this script\n";
155 print " 4. Generally unwise to blindly trust CAs without manual review & verification\n";
156 print " 5. Mozilla apps use additional security checks are not represented in certdata\n";
157 print " 6. Use of this script makes a security engineer grind his teeth and\n";
158 print " swear at you. ;)\n";
159 exit;
160 }
161 else { # Short Form Warning
162 print "Warning: Use of this script may pose some risk, -d risk for more details.\n";
163 }
164}
166sub HELP_MESSAGE() {
167 print "Usage:\t${0} [-b] [-d<certdata>] [-f] [-i] [-k] [-l] [-n] [-p<purposes:levels>] [-q] [-s<algorithms>] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
168 print "\t-b\tbackup an existing version of ca-bundle.crt\n";
169 print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n";
170 print "\t\t Valid names are:\n";
171 print "\t\t ", join(", ", map { ($_ =~ m/$opt_d/) ? "$_ (default)" : $_ } sort keys %urls), "\n";
172 print "\t-f\tforce rebuild even if certdata.txt is current\n";
173 print "\t-i\tprint version info about used modules\n";
174 print "\t-k\tallow URLs other than HTTPS, enable HTTP fallback (insecure)\n";
175 print "\t-l\tprint license info about certdata.txt\n";
176 print "\t-m\tinclude meta data in output (SHA-256 fingerprints are included by default)\n";
177 print "\t-n\tno download of certdata.txt (to use existing)\n";
178 print wrap("\t","\t\t", "-p\tlist of Mozilla trust purposes and levels for certificates to include in output. " .
179 "Takes the form of a comma separated list of purposes, a colon, and a comma separated list of levels. " .
180 "(default: $default_mozilla_trust_purposes:$default_mozilla_trust_levels)"), "\n";
181 print "\t\t Valid purposes are:\n";
182 print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_mozilla_trust_purposes)), "\n";
183 print "\t\t Valid levels are:\n";
184 print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_mozilla_trust_levels)), "\n";
185 print "\t-q\tbe really quiet (no progress output at all)\n";
186 print wrap("\t","\t\t", "-s\tcomma separated list of certificate signatures/hashes to output in plain text mode. (default: $default_signature_algorithms)\n");
187 print "\t\t Valid signature algorithms are:\n";
188 print wrap("\t\t ","\t\t ", join(", ", "ALL", @valid_signature_algorithms)), "\n";
189 print "\t-t\tinclude plain text listing of certificates\n";
190 print "\t-u\tunlink (remove) certdata.txt after processing\n";
191 print "\t-v\tbe verbose and print out processed CAs\n";
192 print "\t-w <l>\twrap base64 output lines after <l> chars (default: ${opt_w})\n";
193 print "\t-x\texclude list of SHA-256 fingerprints. Comma separated, case-insensitive, whitespace and ':' byte delimiters are ignored.\n";
194 exit;
195}
197sub VERSION_MESSAGE() {
198 print "${0} version ${version} running Perl ${]} on ${^O}\n";
199}
201warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i);
202HELP_MESSAGE() if($opt_h);
204sub report($@) {
205 my $output = shift;
207 print STDERR $output . "\n" unless $opt_q;
208}
210sub is_in_list($@) {
211 my $target = shift;
213 return defined(List::Util::first { $target eq $_ } @_);
214}
216# Parses $param_string as a case insensitive comma separated list with optional
217# whitespace validates that only allowed parameters are supplied
218sub parse_csv_param($$@) {
219 my $description = shift;
220 my $param_string = shift;
221 my @valid_values = @_;
223 my @values = map {
224 s/^\s+//; # strip leading spaces
225 s/\s+$//; # strip trailing spaces
226 uc $_ # return the modified string as upper case
227 } split(',', $param_string);
229 # Find all values which are not in the list of valid values or "ALL"
230 my @invalid = grep { !is_in_list($_, "ALL", @valid_values) } @values;
232 if(scalar(@invalid) > 0) {
233 # Tell the user which parameters were invalid and print the standard help
234 # message which also exits
235 print "Error: Invalid ", $description, scalar(@invalid) == 1 ? ": " : "s: ", join(", ", map { "\"$_\"" } @invalid), "\n";
236 HELP_MESSAGE();
237 }
239 @values = @valid_values if(is_in_list("ALL", @values));
241 return @values;
242}
244sub sha256 {
245 my $result;
246 if($Digest::SHA::VERSION || $Digest::SHA::PurePerl::VERSION) {
247 open(FILE, $_[0]) or die "Could not open '$_[0]': $!";
248 binmode(FILE);
249 $result = $MOD_SHA->new(256)->addfile(*FILE)->hexdigest;
250 close(FILE);
251 }
252 else {
253 # Use OpenSSL command if Perl Digest::SHA modules not available
254 open(my $fh, '-|', $openssl, 'dgst', '-r', '-sha256', $_[0]) or die "Failed running openssl on '$_[0]': $!";
255 $result = <$fh>; # read first line
256 close $fh;
257 $result =~ s/^([0-9a-f]{64}) .+/$1/is;
258 }
259 return $result;
260}
262sub oldhash {
263 my $hash = "";
264 open(C, "<", $_[0]) or return 0;
265 while(<C>) {
266 chomp;
267 if($_ =~ /^\#\# SHA256: (.*)/) {
268 $hash = $1;
269 last;
270 }
271 }
272 close(C);
273 return $hash;
274}
276if($opt_p !~ m/:/) {
277 print "Error: Mozilla trust identifier list must include both purposes and levels\n";
278 HELP_MESSAGE();
279}
281(my $included_mozilla_trust_purposes_string, my $included_mozilla_trust_levels_string) = split(':', $opt_p);
282my @included_mozilla_trust_purposes = parse_csv_param("trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes);
283my @included_mozilla_trust_levels = parse_csv_param("trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels);
285my @included_signature_algorithms = parse_csv_param("signature algorithm", $opt_s, @valid_signature_algorithms);
287sub should_output_cert(%) {
288 my %trust_purposes_by_level = @_;
290 foreach my $level (@included_mozilla_trust_levels) {
291 # for each level we want to output, see if any of our desired purposes are
292 # included
293 return 1 if(defined(List::Util::first { is_in_list($_, @included_mozilla_trust_purposes) } @{$trust_purposes_by_level{$level}}));
294 }
296 return 0;
297}
299my $crt = $ARGV[0] || 'ca-bundle.crt';
300(my $txt = $url) =~ s@(.*/|\?.*)@@g;
302my $stdout = $crt eq '-';
303my $resp;
304my $fetched;
306my $oldhash = oldhash($crt);
308my @opt_x_list;
309if($opt_x) {
310 $opt_x = uc $opt_x;
311 $opt_x =~ s/[\s:]//g;
312 @opt_x_list = split(/,/, $opt_x);
313}
315report "SHA256 of old file: $oldhash";
317if(!$opt_n) {
318 report "Using URL: $url";
319 report "Downloading $txt ...";
321 # If we have an HTTPS URL then use curl
322 if($url =~ /^https:\/\//i) {
323 my $curl = qx(curl -V);
324 if($curl) {
325 if($curl =~ /^Protocols:.* https( |$)/m) {
326 report "Get certdata with curl!";
327 my @opts = ();
328 push @opts, '--proto', '=https' if !$opt_k;
329 push @opts, '-s' if $opt_q;
330 my $out = '';
331 if(open(my $fh, '-|', 'curl', '-Lw', '%{response_code}', (@opts), '-o', $txt, $url)) {
332 $out = <$fh>; # read first line
333 chomp $out;
334 close $fh;
335 }
336 if($out && $out == 200) {
337 $fetched = 1;
338 report "Downloaded $txt";
339 }
340 else {
341 report "Failed downloading via HTTPS with curl";
342 if(-e $txt && !unlink($txt)) {
343 report "Failed to remove '$txt': $!";
344 }
345 }
346 }
347 else {
348 report "curl lacks https support";
349 }
350 }
351 else {
352 report "curl not found";
353 }
354 }
356 # If nothing was fetched then use LWP
357 if(!$fetched) {
358 if($url =~ /^https:\/\//i) {
359 report "Falling back to HTTP";
360 $url =~ s/^https:\/\//http:\/\//i;
361 }
362 if(!$opt_k) {
363 report "URLs other than HTTPS are disabled by default, to enable use -k";
364 exit 1;
365 }
366 report "Get certdata with LWP!";
367 if(!defined(${LWP::UserAgent::VERSION})) {
368 report "LWP is not available (LWP::UserAgent not found)";
369 exit 1;
370 }
371 my $ua = new LWP::UserAgent(agent => "$0/$version");
372 $ua->env_proxy();
373 $resp = $ua->mirror($url, $txt);
374 if($resp && $resp->code eq '304') {
375 report "Not modified";
376 exit 0 if -e $crt && !$opt_f;
377 }
378 else {
379 $fetched = 1;
380 report "Downloaded $txt";
381 }
382 if(!$resp || $resp->code !~ /^(?:200|304)$/) {
383 report "Unable to download latest data: "
384 . ($resp? $resp->code . ' - ' . $resp->message : "LWP failed");
385 exit 1 if -e $crt || ! -r $txt;
386 }
387 }
388}
390my $filedate = $resp ? $resp->last_modified : (stat($txt))[9];
391my $datesrc = "as of";
392if(!$filedate) {
393 # mxr.mozilla.org gave us a time, hg.mozilla.org does not!
394 $filedate = time();
395 $datesrc = "downloaded on";
396}
398# get the hash from the download file
399my $newhash = sha256($txt);
401if(!$opt_f && $oldhash eq $newhash) {
402 report "Downloaded file identical to previous run\'s source file. Exiting";
403 if($opt_u && -e $txt && !unlink($txt)) {
404 report "Failed to remove $txt: $!\n";
405 }
406 exit;
407}
409report "SHA256 of new file: $newhash";
411my $currentdate = scalar gmtime($filedate);
413my $format = $opt_t ? "plain text and " : "";
414if($stdout) {
415 open(CRT, '> -') or die "Could not open STDOUT: $!\n";
416}
417else {
418 open(CRT, ">", "$crt.~") or die "Could not open $crt.~: $!\n";
419}
420print CRT <<EOT;
421##
422## Bundle of CA Root Certificates
423##
424## Certificate data from Mozilla ${datesrc}: ${currentdate} GMT
425##
426## Find updated versions here: https://curl.se/docs/caextract.html
427##
428## This is a bundle of X.509 certificates of public Certificate Authorities
429## (CA). These were automatically extracted from Mozilla's root certificates
430## file (certdata.txt). This file can be found in the mozilla source tree:
431## ${url}
432##
433## It contains the certificates in ${format}PEM format and therefore
434## can be directly used with curl / libcurl / php_curl, or with
435## an Apache+mod_ssl webserver for SSL client authentication.
436## Configure this file as the SSLCACertificateFile.
437##
438## Conversion done with mk-ca-bundle.pl version $version.
439## SHA256: $newhash
440##
442EOT
444report "Processing '$txt' ...";
445my $caname;
446my $certnum = 0;
447my $skipnum = 0;
448my $start_of_cert = 0;
449my $main_block = 0;
450my $main_block_name;
451my $trust_block = 0;
452my $trust_block_name;
453my @precert;
454my $cka_value;
455my $valid = 0;
457open(TXT, $txt) or die "Could not open $txt: $!\n";
458while(<TXT>) {
459 if(/\*\*\*\*\* BEGIN LICENSE BLOCK \*\*\*\*\*/) {
460 print CRT;
461 print if($opt_l);
462 while(<TXT>) {
463 print CRT;
464 print if($opt_l);
465 last if(/\*\*\*\*\* END LICENSE BLOCK \*\*\*\*\*/);
466 }
467 next;
468 }
469 # The input file format consists of blocks of Mozilla objects.
470 # The blocks are separated by blank lines but may be related.
471 elsif(/^\s*$/) {
472 $main_block = 0;
473 $trust_block = 0;
474 next;
475 }
476 # Each certificate has a main block.
477 elsif(/^# Certificate "(.*)"/) {
478 (!$main_block && !$trust_block) or die "Unexpected certificate block";
479 $main_block = 1;
480 $main_block_name = $1;
481 # Reset all other certificate variables.
482 $trust_block = 0;
483 $trust_block_name = "";
484 $valid = 0;
485 $start_of_cert = 0;
486 $caname = "";
487 $cka_value = "";
488 undef @precert;
489 next;
490 }
491 # Each certificate's main block is followed by a trust block.
492 elsif(/^# Trust for (?:Certificate )?"(.*)"/) {
493 (!$main_block && !$trust_block) or die "Unexpected trust block";
494 $trust_block = 1;
495 $trust_block_name = $1;
496 if($main_block_name ne $trust_block_name) {
497 die "cert name \"$main_block_name\" != trust name \"$trust_block_name\"";
498 }
499 next;
500 }
501 # Ignore other blocks.
502 #
503 # There is a documentation comment block, a BEGINDATA block, and a bunch of
504 # blocks starting with "# Explicitly Distrust <certname>".
505 #
506 # The latter is for certificates that have already been removed and are not
507 # included. Not all explicitly distrusted certificates are ignored at this
508 # point, only those without an actual certificate.
509 elsif(!$main_block && !$trust_block) {
510 next;
511 }
512 elsif(/^#/) {
513 # The commented lines in a main block are plaintext metadata that describes
514 # the certificate. Issuer, Subject, Fingerprint, etc.
515 if($main_block) {
516 push @precert, $_ if not /^#$/;
517 if(/^# Not Valid After : (.*)/) {
518 my $stamp = $1;
519 use Time::Piece;
520 # Not Valid After : Thu Sep 30 14:01:15 2021
521 my $t = Time::Piece->strptime($stamp, "%a %b %d %H:%M:%S %Y");
522 my $delta = ($t->epoch - time()); # negative means no longer valid
523 if($delta < 0) {
524 $skipnum++;
525 report "Skipping: $main_block_name is not valid anymore" if($opt_v);
526 $valid = 0;
527 }
528 else {
529 $valid = 1;
530 }
531 }
532 }
533 next;
534 }
535 elsif(!$valid) {
536 next;
537 }
539 chomp;
541 if($main_block) {
542 if(/^CKA_CLASS CK_OBJECT_CLASS CKO_CERTIFICATE/) {
543 !$start_of_cert or die "Duplicate CKO_CERTIFICATE object";
544 $start_of_cert = 1;
545 next;
546 }
547 elsif(!$start_of_cert) {
548 next;
549 }
550 elsif(/^CKA_LABEL UTF8 \"(.*)\"/) {
551 ($caname eq "") or die "Duplicate CKA_LABEL attribute";
552 $caname = $1;
553 if($caname ne $main_block_name) {
554 die "caname \"$caname\" != cert name \"$main_block_name\"";
555 }
556 next;
557 }
558 elsif(/^CKA_VALUE MULTILINE_OCTAL/) {
559 ($cka_value eq "") or die "Duplicate CKA_VALUE attribute";
560 while(<TXT>) {
561 last if(/^END/);
562 chomp;
563 my @octets = split(/\\/);
564 shift @octets;
565 for(@octets) {
566 $cka_value .= chr(oct);
567 }
568 }
569 next;
570 }
571 else {
572 next;
573 }
574 }
576 if(!$trust_block || !$start_of_cert || $caname eq "" || $cka_value eq "") {
577 die "Certificate extraction failed";
578 }
580 my %trust_purposes_by_level;
582 if(/^CKA_CLASS CK_OBJECT_CLASS CKO_NSS_TRUST/) {
583 # now scan the trust part to determine how we should trust this cert
584 while(<TXT>) {
585 if(/^\s*$/) {
586 $trust_block = 0;
587 last;
588 }
589 if(/^CKA_TRUST_([A-Z_]+)\s+CK_TRUST\s+CKT_NSS_([A-Z_]+)\s*$/) {
590 if(!is_in_list($1, @valid_mozilla_trust_purposes)) {
591 report "Warning: Unrecognized trust purpose for cert: $caname. Trust purpose: $1. Trust Level: $2";
592 }
593 elsif(!is_in_list($2, @valid_mozilla_trust_levels)) {
594 report "Warning: Unrecognized trust level for cert: $caname. Trust purpose: $1. Trust Level: $2";
595 }
596 else {
597 push @{$trust_purposes_by_level{$2}}, $1;
598 }
599 }
600 }
602 # Sanity check that an explicitly distrusted certificate only has trust
603 # purposes with a trust level of NOT_TRUSTED.
604 #
605 # Certificate objects that are explicitly distrusted are in a certificate
606 # block that starts # Certificate "Explicitly Distrust(ed) <certname>",
607 # where "Explicitly Distrust(ed) " was prepended to the original cert name.
608 if($caname =~ /distrust/i ||
609 $main_block_name =~ /distrust/i ||
610 $trust_block_name =~ /distrust/i) {
611 my @levels = keys %trust_purposes_by_level;
612 if(scalar(@levels) != 1 || $levels[0] ne "NOT_TRUSTED") {
613 die "\"$caname\" must have all trust purposes at level NOT_TRUSTED.";
614 }
615 }
617 if(!should_output_cert(%trust_purposes_by_level)) {
618 $skipnum++;
619 report "Skipping: $caname lacks acceptable trust level" if($opt_v);
620 }
621 else {
622 # Skip if explicitly excluded
623 if($opt_x) {
624 my ($fingerprint_sha256) = grep { /^# Fingerprint .*SHA.*256/i } @precert;
625 $fingerprint_sha256 =~ s/://g;
626 $fingerprint_sha256 = uc $fingerprint_sha256;
627 ($fingerprint_sha256) = $fingerprint_sha256 =~ /([A-F0-9]{64})/;
628 if(grep { $_ eq $fingerprint_sha256 } @opt_x_list) {
629 report "Skipping: '$main_block_name' fingerprint explicitly excluded: $fingerprint_sha256";
630 $skipnum++;
631 next;
632 }
633 }
635 my $encoded = MIME::Base64::encode_base64($cka_value, '');
636 $encoded =~ s/(.{1,${opt_w}})/$1\n/g;
637 my $pem = "-----BEGIN CERTIFICATE-----\n"
638 . $encoded
639 . "-----END CERTIFICATE-----\n";
640 print CRT "\n$caname\n";
641 my $maxStringLength = length(decode('UTF-8', $caname, Encode::FB_CROAK | Encode::LEAVE_SRC));
642 print CRT ("=" x $maxStringLength . "\n");
643 if($opt_t) {
644 foreach my $key (sort keys %trust_purposes_by_level) {
645 my $string = $key . ": " . join(", ", @{$trust_purposes_by_level{$key}});
646 print CRT $string . "\n";
647 }
648 }
649 if($opt_m) {
650 print CRT for @precert;
651 }
652 else {
653 print CRT for grep { /^# Fingerprint .*SHA.*256/i } @precert;
654 }
655 if(!$opt_t) {
656 print CRT $pem;
657 }
658 else {
659 my $pipe = "";
660 foreach my $hash (@included_signature_algorithms) {
661 $pipe = "|$openssl x509 -" . $hash . " -fingerprint -noout -inform PEM";
662 if(!$stdout) {
663 $pipe .= " >> $crt.~";
664 close(CRT) or die "Could not close $crt.~: $!";
665 }
666 open(TMP, $pipe) or die "Could not open openssl pipe: $!";
667 print TMP $pem;
668 close(TMP) or die "Could not close openssl pipe: $!";
669 if(!$stdout) {
670 open(CRT, ">>", "$crt.~") or die "Could not open $crt.~: $!";
671 }
672 }
673 $pipe = "|$openssl x509 -text -inform PEM";
674 if(!$stdout) {
675 $pipe .= " >> $crt.~";
676 close(CRT) or die "Could not close $crt.~: $!";
677 }
678 open(TMP, $pipe) or die "Could not open openssl pipe: $!";
679 print TMP $pem;
680 close(TMP) or die "Could not close openssl pipe: $!";
681 if(!$stdout) {
682 open(CRT, ">>", "$crt.~") or die "Could not open $crt.~: $!";
683 }
684 }
685 report "Processed: $caname" if($opt_v);
686 $certnum++;
687 }
688 }
689}
690close(TXT) or die "Could not close $txt: $!\n";
691close(CRT) or die "Could not close $crt.~: $!\n";
692utime($filedate, $filedate, "$crt.~");
693unless($stdout) {
694 if($opt_b && -e $crt) {
695 my $bk = 1;
696 while(-e "$crt.~${bk}~") {
697 $bk++;
698 }
699 rename $crt, "$crt.~${bk}~" or die "Failed to create backup $crt.~$bk}~: $!\n";
700 }
701 elsif(-e $crt) {
702 unlink($crt) or die "Failed to remove $crt: $!\n";
703 }
704 rename "$crt.~", $crt or die "Failed to rename $crt.~ to $crt: $!\n";
705}
706if($opt_u && -e $txt && !unlink($txt)) {
707 report "Failed to remove $txt: $!\n";
708}
709report "Done ($certnum CA certs processed, $skipnum skipped).";
Diagnostics4 git calls · 43 ms
CallStatusSizeTime043 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit17 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=17 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2008.8 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=24 git.response.bytes=8986 git.response.cache=HIT git.response.duration_ms=24 git.fetch.wants=3174c54f7aa48a67b04ae8049563fc279c3053d6 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=8986 git.pkt.payload.max=8965 git.sideband.band1.bytes=8964 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1d894abdfa151
- Request
- 9a5d9c74…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format