mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 22:26:06 +02:00
Updated DKIM requirements
This commit is contained in:
@@ -1836,6 +1836,7 @@ public class MessageHelper {
|
||||
boolean checkDKIMRequirements() throws MessagingException {
|
||||
ensureHeaders();
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc6376/
|
||||
String[] headers = imessage.getHeader("DKIM-Signature");
|
||||
if (headers == null || headers.length < 1)
|
||||
return false;
|
||||
@@ -1843,6 +1844,12 @@ public class MessageHelper {
|
||||
for (String header : headers) {
|
||||
Map<String, String> kv = getKeyValues(MimeUtility.unfold(header));
|
||||
|
||||
// Algorithm
|
||||
// https://tools.ietf.org/id/draft-ietf-dcrup-dkim-usage-03.html#rfc.section.4.3
|
||||
String a = kv.get("a");
|
||||
if ("rsa-sha1".equals(a))
|
||||
return false;
|
||||
|
||||
// Hashed body length
|
||||
Integer l = Helper.parseInt(kv.get("l"));
|
||||
if (l != null && l == 0) {
|
||||
@@ -1856,15 +1863,6 @@ public class MessageHelper {
|
||||
Log.w("DKIM header fields missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] hs = h
|
||||
.toLowerCase(Locale.ROOT)
|
||||
.replaceAll("\\s+", "")
|
||||
.split(":");
|
||||
if (!Arrays.asList(hs).contains("from")) {
|
||||
Log.i("DKIM headers fields missing 'from' fields=" + h);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user