1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-30 19:56:10 +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;
// Fallback: check server/certificate IP address
try {
InetAddress ip = InetAddress.getByName(server);
for (String name : names) {
if (name.startsWith("*."))
name = name.substring(2);
if (!harden)
try {
InetAddress ip = InetAddress.getByName(server);
for (String name : names) {
if (name.startsWith("*."))
name = name.substring(2);
try {
for (InetAddress addr : InetAddress.getAllByName(name))
if (Arrays.equals(ip.getAddress(), addr.getAddress())) {
Log.i("Accepted " + name + " for " + server);
return;
}
} catch (UnknownHostException ex) {
Log.w(ex);
try {
for (InetAddress addr : InetAddress.getAllByName(name))
if (Arrays.equals(ip.getAddress(), addr.getAddress())) {
Log.i("Accepted " + name + " for " + server);
return;
}
} catch (UnknownHostException 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);
Log.i(error);