Class Tls12SocketFactory



  • public class Tls12SocketFactory
    extends javax.net.ssl.SSLSocketFactory

    Applies the correct ConnectionSpecs for different versions of android. On api versions from 16-20 (Jelly Bean and Kitkat) a patch is applied to the SSLSocketFactory to enable TLSv1.2 and disable older TLS and SSL versions.

    On Api versions >= 21 (Lollipop and above) TLSv1.2 is supported by default and the default SSLSocketFactory is used. The Connection spec is set to disable older fallback versions of TLS and SSL.

    more info OkHttp Github Issue

    • Constructor Summary

      Constructors 
      Constructor and Description
      Tls12SocketFactory(javax.net.ssl.SSLSocketFactory base) 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.net.Socket createSocket(java.net.InetAddress host, int port) 
      java.net.Socket createSocket(java.net.InetAddress address, int port, java.net.InetAddress localAddress, int localPort) 
      java.net.Socket createSocket(java.net.Socket s, java.lang.String host, int port, boolean autoClose) 
      java.net.Socket createSocket(java.lang.String host, int port) 
      java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort) 
      static javax.net.ssl.HttpsURLConnection enableTls12(javax.net.ssl.HttpsURLConnection httpURLConnection) 
      java.lang.String[] getDefaultCipherSuites() 
      java.lang.String[] getSupportedCipherSuites() 
      • Methods inherited from class javax.net.ssl.SSLSocketFactory

        createSocket, getDefault
      • Methods inherited from class javax.net.SocketFactory

        createSocket
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Tls12SocketFactory

        public Tls12SocketFactory(javax.net.ssl.SSLSocketFactory base)
    • Method Detail

      • enableTls12

        public static javax.net.ssl.HttpsURLConnection enableTls12(javax.net.ssl.HttpsURLConnection httpURLConnection)
      • getDefaultCipherSuites

        public java.lang.String[] getDefaultCipherSuites()
        Specified by:
        getDefaultCipherSuites in class javax.net.ssl.SSLSocketFactory
      • getSupportedCipherSuites

        public java.lang.String[] getSupportedCipherSuites()
        Specified by:
        getSupportedCipherSuites in class javax.net.ssl.SSLSocketFactory
      • createSocket

        public java.net.Socket createSocket(java.net.Socket s,
                                            java.lang.String host,
                                            int port,
                                            boolean autoClose)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.ssl.SSLSocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket(java.lang.String host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket(java.lang.String host,
                                            int port,
                                            java.net.InetAddress localHost,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket(java.net.InetAddress host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket(java.net.InetAddress address,
                                            int port,
                                            java.net.InetAddress localAddress,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in class javax.net.SocketFactory
        Throws:
        java.io.IOException