Loading src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java +111 −99 Original line number Diff line number Diff line Loading @@ -24,7 +24,17 @@ package com.owncloud.android.lib.common.network; import com.owncloud.android.lib.common.utils.Log_OC; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import java.io.IOException; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; Loading @@ -41,15 +51,6 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import com.owncloud.android.lib.common.utils.Log_OC; /** * AdvancedSSLProtocolSocketFactory allows to create SSL {@link Socket}s with Loading @@ -66,10 +67,6 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { private AdvancedX509TrustManager mTrustManager = null; private X509HostnameVerifier mHostnameVerifier = null; public SSLContext getSslContext() { return mSslContext; } /** * Constructor for AdvancedSSLProtocolSocketFactory. */ Loading @@ -89,6 +86,10 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { mHostnameVerifier = hostnameVerifier; } public SSLContext getSslContext() { return mSslContext; } /** * @see ProtocolSocketFactory#createSocket(java.lang.String, int, java.net.InetAddress, int) */ Loading Loading @@ -151,9 +152,7 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { * @param clientHost the local host name/IP to bind the socket to * @param clientPort the port on the local machine * @param params {@link HttpConnectionParams Http connection parameters} * * @return Socket a new socket * * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined Loading @@ -177,7 +176,19 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { Socket socket = socketfactory.createSocket(); enableSecureProtocols(socket); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(host, port); InetAddress address = InetAddress.getByName(host); if (address instanceof Inet6Address) { InetAddress[] inetAddressArray = InetAddress.getAllByName(host); for (InetAddress inetAddress : inetAddressArray) { if (inetAddress instanceof Inet4Address) { address = inetAddress; break; } } } SocketAddress remoteaddr = new InetSocketAddress(address, port); socket.setSoTimeout(params.getSoTimeout() * 5); socket.bind(localaddr); ServerNameIndicator.setServerNameIndication(host, (SSLSocket) socket); Loading Loading @@ -236,6 +247,7 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { * * Then, the host name is compared with the content of the server certificate using the current host name verifier, * if any. * * @param socket */ private void verifyPeerIdentity(String host, int port, Socket socket) throws IOException { Loading Loading
src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java +111 −99 Original line number Diff line number Diff line Loading @@ -24,7 +24,17 @@ package com.owncloud.android.lib.common.network; import com.owncloud.android.lib.common.utils.Log_OC; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import java.io.IOException; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; Loading @@ -41,15 +51,6 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.params.HttpConnectionParams; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; import com.owncloud.android.lib.common.utils.Log_OC; /** * AdvancedSSLProtocolSocketFactory allows to create SSL {@link Socket}s with Loading @@ -66,10 +67,6 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { private AdvancedX509TrustManager mTrustManager = null; private X509HostnameVerifier mHostnameVerifier = null; public SSLContext getSslContext() { return mSslContext; } /** * Constructor for AdvancedSSLProtocolSocketFactory. */ Loading @@ -89,6 +86,10 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { mHostnameVerifier = hostnameVerifier; } public SSLContext getSslContext() { return mSslContext; } /** * @see ProtocolSocketFactory#createSocket(java.lang.String, int, java.net.InetAddress, int) */ Loading Loading @@ -151,9 +152,7 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { * @param clientHost the local host name/IP to bind the socket to * @param clientPort the port on the local machine * @param params {@link HttpConnectionParams Http connection parameters} * * @return Socket a new socket * * @throws IOException if an I/O error occurs while creating the socket * @throws UnknownHostException if the IP address of the host cannot be * determined Loading @@ -177,7 +176,19 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { Socket socket = socketfactory.createSocket(); enableSecureProtocols(socket); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(host, port); InetAddress address = InetAddress.getByName(host); if (address instanceof Inet6Address) { InetAddress[] inetAddressArray = InetAddress.getAllByName(host); for (InetAddress inetAddress : inetAddressArray) { if (inetAddress instanceof Inet4Address) { address = inetAddress; break; } } } SocketAddress remoteaddr = new InetSocketAddress(address, port); socket.setSoTimeout(params.getSoTimeout() * 5); socket.bind(localaddr); ServerNameIndicator.setServerNameIndication(host, (SSLSocket) socket); Loading Loading @@ -236,6 +247,7 @@ public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { * * Then, the host name is compared with the content of the server certificate using the current host name verifier, * if any. * * @param socket */ private void verifyPeerIdentity(String host, int port, Socket socket) throws IOException { Loading