hello i am getting this error when trying to connect to SSL in java using the SSLFactory
Stack trace:
javax.net.ssl.SSLHandshakeException: invalid SSL record content type
at com.ibm.j9.jsse.SSLSocketImpl.completeHandshake(Unknown Source)
at com.ibm.j9.jsse.SSLSocketImpl.getInputStream(Unknown Source)
Here’s the code error during handshake:
_socket = SocketFactory.getSslSocket( _socket, //Socket created before this call
_address, //host that supports SSL
_port.intValue() );
SSLSocket tempSocket = (SSLSocket)_socket;
String[] supportedCipherSuites = tempSocket.getSupportedCipherSuites();
System.out.println( "Supported Cipher Suites:" );
for( int i = 0; i < supportedCipherSuites.length; i++ )
{
System.out.println( supportedCipherSuites[i] );
}
tempSocket.setUseClientMode( true );
tempSocket.startHandshake();
getSupportedCipherSuites()only shows you which ciphers your local SSL implementation can support (regardless of whether they are enabled or not); It does not use the remote connection. So your “debug” output is always going to succeed with the same results, regardless of the target of yourSSLSocket. The remote connection is not opened until you attempt to handshake (or if a handshake is forced by attempting to read or write to the stream, or access SSL session information).Are you confident the outbound TCP connection you are making is to an SSL server? Have you been able to confirm this with a different client, such as a browser or the OpenSSL command line client?