diff --git a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java index 6574809a..12114922 100644 --- a/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java +++ b/src/org/kde/kdeconnect/Backends/LanBackend/LanLinkProvider.java @@ -253,7 +253,9 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis //Handshake is blocking, so do it on another thread and free this thread to keep receiving new connection new Thread(() -> { try { - sslsocket.startHandshake(); + synchronized (this) { + sslsocket.startHandshake(); + } } catch (Exception e) { Log.e("KDE/LanLinkProvider", "Handshake failed with " + identityPacket.getString("deviceName")); e.printStackTrace(); @@ -286,7 +288,7 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis * @param connectionOrigin which side started this connection * @throws IOException if an exception is thrown by {@link LanLink#reset(Socket, LanLink.ConnectionStarted)} */ - private synchronized void addLink(final NetworkPacket identityPacket, Socket socket, LanLink.ConnectionStarted connectionOrigin) throws IOException { + private void addLink(final NetworkPacket identityPacket, Socket socket, LanLink.ConnectionStarted connectionOrigin) throws IOException { String deviceId = identityPacket.getString("deviceId"); LanLink currentLink = visibleComputers.get(deviceId); diff --git a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java index 758fd7a7..25ce5c87 100644 --- a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java @@ -42,6 +42,7 @@ import org.spongycastle.operator.jcajce.JcaContentSignerBuilder; import java.io.IOException; import java.math.BigInteger; import java.net.Socket; +import java.net.SocketException; import java.security.KeyStore; import java.security.MessageDigest; import java.security.PrivateKey; @@ -201,7 +202,7 @@ public class SslHelper { } - public static void configureSslSocket(SSLSocket socket, boolean isDeviceTrusted, boolean isClient) { + public static void configureSslSocket(SSLSocket socket, boolean isDeviceTrusted, boolean isClient) throws SocketException { socket.setEnabledProtocols(new String[]{"TLSv1"}); //Newer TLS versions are only supported on API 16+ @@ -223,6 +224,8 @@ public class SslHelper { } socket.setEnabledCipherSuites(supportedCiphers.toArray(new String[supportedCiphers.size()])); + socket.setSoTimeout(1000); + if (isClient) { socket.setUseClientMode(true); } else {