Fixed S/MIME canonicalization

This commit is contained in:
M66B
2021-09-18 13:15:47 +02:00
parent 3a4ea76b4f
commit a9e635b997
3 changed files with 8 additions and 3 deletions

View File

@@ -2333,9 +2333,13 @@ public class MessageHelper {
if (parts.length < 2)
throw new ParseException("Signed part missing");
// PGP: https://datatracker.ietf.org/doc/html/rfc3156#section-5
// S/MIME: https://datatracker.ietf.org/doc/html/rfc8551#section-3.1.1
String c = parts[1]
.replaceAll(" +$", "") // trim trailing spaces
.replaceAll("\\r?\\n", "\r\n"); // normalize new lines
if (EntityAttachment.PGP_CONTENT.equals(apart.encrypt))
c = c.replaceAll(" +$", ""); // trim trailing spaces
try (OutputStream os = new FileOutputStream(file)) {
os.write(c.getBytes());
}