From bad22999ea4a21c6958ea16f848734ca7695da16 Mon Sep 17 00:00:00 2001 From: Ian Young Date: Fri, 13 Jun 2008 12:08:30 +0000 Subject: [PATCH] Add tools for folding Base64-encoded embedded certificates so that they meet the MIME requirement of 64 characters per line. --- build.xml | 25 +++++++++++++++++++++++++ build/fold_cert.pl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 build/fold_cert.pl 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