diff --git a/build.xml b/build.xml index 669183ab..0f54bdce 100644 --- a/build.xml +++ b/build.xml @@ -49,6 +49,12 @@ + + + + + + + + Folding embedded certificates + + + + + + + + + + + + + + diff --git a/build/fold_cert.pl b/build/fold_cert.pl new file mode 100755 index 00000000..92122cac --- /dev/null +++ b/build/fold_cert.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w + +# +# The input file is a fragment file that may or may not have one +# or more unfolded X.509 embedded certificates in it. Fold these +# to a max of 64 characters per Base64 line, but preserve +# XML indentation. +# + +$max = 64; # max chars per line + +while (<>) { + if (/^(\s*)\(.*)\<\/ds:X509Certificate\>\s*$/) { + $sp = $1; + $spp = "$1 "; # add four spaces + $cert = $2; + print "$sp\n"; + while (length($cert) != 0) { + $line = $cert; + if (length($line) > $max) { + $line = substr($line, 0, $max) + } + print "$spp$line\n"; + substr($cert, 0, length($line)) = ''; + } + print "$sp\n"; + } else { + print $_; + } +} + +# end