0

The server is grumble (https://github.com/mumble-voip/grumble). I want to code a simple client used for test login server.

Client reported error:

javax.net.ssl.SSLProtocolException: handshake alert:  no_renegotiation
at sun.security.ssl.ClientHandshaker.handshakeAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at sun.security.ssl.AppInputStream.read(Unknown Source)
at java.io.InputStream.read(Unknown Source)
at mumble.main.SSLClient.main(SSLClient.java:97)

Client main code :

    public static void main(String args[]) {
    SSLSocket socket = null;
    X509TrustManager passthroughTrustManager = new X509TrustManager() {
        @Override
        public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }

        @Override
        public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }

        @Override
        public X509Certificate[] getAcceptedIssuers() {
            return new X509Certificate[0];
        }
    };

    try {
        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
        sslContext.init(null, new TrustManager[] { passthroughTrustManager }, null);


        SSLSocketFactory ssf = sslContext.getSocketFactory();
        socket = (SSLSocket) ssf.createSocket(DEFAULT_HOST, DEFAULT_PORT);
        printSocketInfo(socket);

        socket.addHandshakeCompletedListener(new HandshakeCompletedListener() {

            @Override
            public void handshakeCompleted(HandshakeCompletedEvent arg0) {
                // TODO Auto-generated method stub
                System.err.println("handsakeCompleted:" + arg0.getSource().toString());
                flag = false;
            }

        });
        socket.startHandshake();

        peerCertificates = (X509Certificate[]) socket.getSession().getPeerCertificates();
        OutputStream out = socket.getOutputStream();

        // sendVersion(out);
        // sendAuthenticate(out);
        // sendPing(out);
        InputStream in = socket.getInputStream();

        byte[] buffer = new byte[1024 * 10];
        int d = -1;

        while ((d = in.read(buffer)) != -1) {// at mumble.main.SSLClient.main(SSLClient.java:97)
            System.out.println("rec[" + d + "]:" + new String(buffer));
        }

        System.out.println(d);

    } catch (Exception e) {
        System.err.println("Connection failed: " + e.toString());
        e.printStackTrace();
    } finally {
        if (socket != null) {
            try {
                socket.close();
            } catch (IOException ioe) {
            }
            socket = null;
        }
    }

}

private static void printSocketInfo(SSLSocket s) {
    System.out.println("Socket class: " + s.getClass());
    System.out.println("   Remote address = " + s.getInetAddress().toString());
    System.out.println("   Remote port = " + s.getPort());
    System.out.println("   Local socket address = " + s.getLocalSocketAddress().toString());
    System.out.println("   Local address = " + s.getLocalAddress().toString());
    System.out.println("   Local port = " + s.getLocalPort());
    System.out.println("   Need client authentication = " + s.getNeedClientAuth());
    SSLSession ss = s.getSession();
    System.out.println("   Cipher suite = " + ss.getCipherSuite());
    System.out.println("   Protocol = " + ss.getProtocol());
}

The server log: server log image

Why the javax.net.ssl.SSLProtocolException: handshake alert: no_renegotiation happens and how could I fix it?

leo
  • 1
  • 2
  • 1
    Please add a [MCVE]. – Nic Jun 15 '16 at 03:52
  • See this thread: http://stackoverflow.com/questions/33363886/java-ssl-hanshake-alert-no-negotiation – Jorge Campos Jun 15 '16 at 04:02
  • @EJP I disagree with the dupe; no_renegotiation is definitely NOT SNI. It very likely IS 5746 as suggested by Jorge, but here it looks like the client at fault not the server, and any Java (JSSE) client newer than 2010 _should_ be okay. **OP: please give java version**, and if possible get and show either a **network trace** of a connection attempt (wireshark is usually easiest and has very nice display) **or JSSE trace** from sysprop `javax.net.debug=ssl` ? – dave_thompson_085 Jun 15 '16 at 08:40
  • OK. I will do it tomorrow. java version is 1.8.0_77 – leo Jun 15 '16 at 09:57

0 Answers0