Hi,
I’m using mina in two options:
1)      Regular socket
2)      SSLSocket

The regular socket works fine but I have problems with the SSL, the problems
are only with messages bigger than 1.5K !!!
Using the SSL and these messages, I get a corrupted message, I’m
transferring XML and it looks like it changes in the middle to binary mode.
(as you can see below)

                <Element>
                    <Name>RESOURCE_TYPE</Name>
                    <Value1 xsi:type="xs:long"
xmlns:xs="http://www.w3.org/2001/XMLSchema";>1</Value1>
                    <Value2 xsi:type="xs:long"
xmlns:xs="http://www.w3.org/2_ _ _ _ _ _ _ _ _ _

Do you have an idea why it could happen?

My code without SSL:
        Socket socket = null;
        SocketFactory socketFactory = SocketFactory.getDefault();        
        socket =  socketFactory.createSocket("localhost",m_port);
        sendMessage(socket, i_messasge);
        socket.close();

My code with SSL:
        SSLSocket socket = null;
        SSLSocketFactory socketFactory = null;
         
        SSLContext sslContext = createSSLContext();
        socketFactory = sslContext.getSocketFactory();
        socket = (SSLSocket) socketFactory.createSocket("localhost",m_port);
        socket.setUseClientMode(true);
        sendMessage(socket, i_messasge);
        socket.close();

    private SSLContext createSSLContext() throws Exception 
    {
        String keystoreName="dipCompareSrv.ks";
        InputStream is =
ClassLoader.getSystemResourceAsStream(keystoreName);
        if (is == null)
        {
                throw new Exception("Keystore not found:" + keystoreName);
        }
        String keStorePwd="storepwd";
        //Prepare keystore
        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(is, keStorePwd.toCharArray());
    
        //Prepare trust manager factory
        TrustManagerFactory factory =
TrustManagerFactory.getInstance("SunX509");
        factory.init(keyStore);

        //Create SSLContext
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, factory.getTrustManagers(), null);

        return sslContext;
    }

Thanks in advance …
Oren.

-- 
View this message in context: 
http://www.nabble.com/Mina-working-with-SSL-tf4712545s16868.html#a13470299
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to