Skip to content

Commit 0209f80

Browse files
author
XYG6
committed
FIX - missing try catch and wrong test min sdk version
1 parent dcbf80f commit 0209f80

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
import javax.net.ssl.HttpsURLConnection;
3636
import javax.net.ssl.SSLContext;
37+
import javax.net.ssl.SSLParameters;
38+
import javax.net.ssl.SSLSocket;
3739
import javax.net.ssl.TrustManager;
3840
import javax.net.ssl.X509TrustManager;
3941
import android.util.Log;
@@ -199,9 +201,9 @@ public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) {
199201

200202
@Override
201203
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException {
202-
Socket socket = sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
203-
enableSecureProtocols(socket);
204-
return socket;
204+
Socket localSocket = sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
205+
enableSecureProtocols(localSocket);
206+
return localSocket;
205207
}
206208

207209
@Override
@@ -222,8 +224,14 @@ private void enableSecureProtocols(Socket socket) {
222224
String [] supportedProtocols = params.getProtocols();
223225

224226
// activate supported protocols on the socket
225-
Socket socket = sslContext.getSocketFactory().createSocket();
226-
((SSLSocket) socket).setEnabledProtocols(supportedProtocols);
227+
try {
228+
Socket localSocket = sslContext.getSocketFactory().createSocket();
229+
((SSLSocket) localSocket).setEnabledProtocols(supportedProtocols);
230+
}catch (Exception e)
231+
{
232+
233+
}
234+
227235
//((SSLSocket) socket).setEnabledProtocols(new String[] {"TLSv1.2"} );
228236
}
229237

0 commit comments

Comments
 (0)