1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

TLSv1.1 and TLSv1.2 fix

This commit is contained in:
Thorsten Knöller 2014-10-30 17:55:22 +01:00
parent 5bd0d73877
commit 539ea8f71a

View File

@ -86,6 +86,7 @@ public class AdvancedSslSocketFactory implements ProtocolSocketFactory {
*/ */
public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException { public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException {
Socket socket = mSslContext.getSocketFactory().createSocket(host, port, clientHost, clientPort); Socket socket = mSslContext.getSocketFactory().createSocket(host, port, clientHost, clientPort);
((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"});
verifyPeerIdentity(host, port, socket); verifyPeerIdentity(host, port, socket);
return socket; return socket;
} }
@ -161,6 +162,7 @@ public class AdvancedSslSocketFactory implements ProtocolSocketFactory {
SocketFactory socketfactory = mSslContext.getSocketFactory(); SocketFactory socketfactory = mSslContext.getSocketFactory();
Log_OC.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout()); Log_OC.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout());
Socket socket = socketfactory.createSocket(); Socket socket = socketfactory.createSocket();
((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"});
SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
SocketAddress remoteaddr = new InetSocketAddress(host, port); SocketAddress remoteaddr = new InetSocketAddress(host, port);
socket.setSoTimeout(params.getSoTimeout()); socket.setSoTimeout(params.getSoTimeout());
@ -178,6 +180,7 @@ public class AdvancedSslSocketFactory implements ProtocolSocketFactory {
UnknownHostException { UnknownHostException {
Log_OC.d(TAG, "Creating SSL Socket with remote " + host + ":" + port); Log_OC.d(TAG, "Creating SSL Socket with remote " + host + ":" + port);
Socket socket = mSslContext.getSocketFactory().createSocket(host, port); Socket socket = mSslContext.getSocketFactory().createSocket(host, port);
((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1", "TLSv1.1", "TLSv1.2"});
verifyPeerIdentity(host, port, socket); verifyPeerIdentity(host, port, socket);
return socket; return socket;
} }