1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 13:14:39 +00:00

Skip IP fallback if harden enabled

This commit is contained in:
M66B 2022-01-30 13:30:29 +01:00
parent f939072fca
commit 157f5a5c19

View file

@ -1019,27 +1019,28 @@ public class EmailService implements AutoCloseable {
return; return;
// Fallback: check server/certificate IP address // Fallback: check server/certificate IP address
try { if (!harden)
InetAddress ip = InetAddress.getByName(server); try {
for (String name : names) { InetAddress ip = InetAddress.getByName(server);
if (name.startsWith("*.")) for (String name : names) {
name = name.substring(2); if (name.startsWith("*."))
name = name.substring(2);
try { try {
for (InetAddress addr : InetAddress.getAllByName(name)) for (InetAddress addr : InetAddress.getAllByName(name))
if (Arrays.equals(ip.getAddress(), addr.getAddress())) { if (Arrays.equals(ip.getAddress(), addr.getAddress())) {
Log.i("Accepted " + name + " for " + server); Log.i("Accepted " + name + " for " + server);
return; return;
} }
} catch (UnknownHostException ex) { } catch (UnknownHostException ex) {
Log.w(ex); Log.w(ex);
}
} }
} catch (UnknownHostException ex) {
Log.w(ex);
} catch (Throwable ex) {
Log.e(ex);
} }
} catch (UnknownHostException ex) {
Log.w(ex);
} catch (Throwable ex) {
Log.e(ex);
}
String error = server + " not in certificate: " + TextUtils.join(",", names); String error = server + " not in certificate: " + TextUtils.join(",", names);
Log.i(error); Log.i(error);