Trust fallback host

This commit is contained in:
M66B 2019-12-18 10:51:51 +01:00
parent cabc14e310
commit b08236b6b7
1 changed files with 2 additions and 2 deletions

View File

@ -232,7 +232,7 @@ public class MailService implements AutoCloseable {
properties.put("mail." + protocol + ".auth.mechanisms", "XOAUTH2"); properties.put("mail." + protocol + ".auth.mechanisms", "XOAUTH2");
//if (BuildConfig.DEBUG) //if (BuildConfig.DEBUG)
// throw new MailConnectException(new SocketConnectException("Debug", new Exception(), host, port, 0)); // throw new MailConnectException(new SocketConnectException("Debug", new Exception("Test"), host, port, 0));
_connect(context, host, port, user, password); _connect(context, host, port, user, password);
return null; return null;
@ -265,12 +265,12 @@ public class MailService implements AutoCloseable {
} catch (MailConnectException ex) { } catch (MailConnectException ex) {
try { try {
// Some devices resolve IPv6 addresses while not having IPv6 connectivity // Some devices resolve IPv6 addresses while not having IPv6 connectivity
properties.put("mail." + protocol + ".ssl.checkserveridentity", "false");
InetAddress[] iaddrs = InetAddress.getAllByName(host); InetAddress[] iaddrs = InetAddress.getAllByName(host);
if (iaddrs.length > 1) if (iaddrs.length > 1)
for (InetAddress iaddr : iaddrs) for (InetAddress iaddr : iaddrs)
try { try {
Log.i("Falling back to " + iaddr.getHostAddress()); Log.i("Falling back to " + iaddr.getHostAddress());
properties.put("mail." + protocol + ".ssl.trust", iaddr.getHostAddress());
_connect(context, iaddr.getHostAddress(), port, user, password); _connect(context, iaddr.getHostAddress(), port, user, password);
return null; return null;
} catch (MessagingException ex1) { } catch (MessagingException ex1) {