-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tools for folding Base64-encoded embedded certificates so that th…
…ey meet the MIME requirement of 64 characters per line.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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\>(.*)\<\/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 |