Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
inc-meta/build/fold_cert.pl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
32 lines (28 sloc)
719 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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\>(.*)\<\/ds:X509Certificate\>\s*$/) { | |
$sp = $1; | |
$spp = "$1 "; # add four spaces | |
$cert = $2; | |
print "$sp<ds:X509Certificate>\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</ds:X509Certificate>\n"; | |
} else { | |
print $_; | |
} | |
} | |
# end |