I am attempting to connect to an ssl server that isn't a web site.  I have
C++ client code that works and would like to get a java client working.  My
initial attempt fails with a 



Exception in thread "main" gnu.javax.net.ssl.provider.AlertException:
ILLEGAL_PARAMETER: remotely generated; FATAL


message.  That's not surprising since it is a simple program that does
essentially:


        SocketFactory sf = SSLSocketFactory.getDefault();
        Socket s = sf.createSocket(args[0], Integer.parseInt(args[1]));
        BufferedOutputStream bro = new
BufferedOutputStream(s.getOutputStream());
        bro.write(buf,0,msgLen);


And fails on the write.

So I decided to add a context, since that's what the C++ code did.



   SSLContext sc = SSLContext.getInstance ( "SSLv3" ) ; 
   sc.init (null,null,null) ; 
   sc.createSSLEngine();
   SocketFactory sf = sc.getSocketFactory();


This gives the same result.  In the C++ code I specify a cipher, like:


            if (!SSL_CTX_set_cipher_list (ptrCTX, "ADH")) {
            ptrSSL = SSL_new (ptrCTX);
            int xx = SSL_set_fd (ptrSSL, fdSocket);

But I can't find a way to set a cipher into the context.  The only mention
of ciphers in the API seem to be in the SSLEngine class and I can't find a
way to link that class into what I'm doing, so I'm pretty well stuck at this
point.

So one question, is that "SSLv3" an acceptable protocol?  The only examples
I've found set that to "SSL" but in the C++ code I have:


            SSL_METHOD *method;
            method = SSLv3_client_method ();
            ptrCTX = SSL_CTX_new (method);

I have no idea if that's the equivalent or not, I'm searching in the dark. 
I have read the "SSL and TLS" book but it like most examples assumes an http
client which this is not.


Another question is how do I specify a cipher and/or do I have to? 
 


Thanks for any pointers.


Jim.






-- 
View this message in context: 
http://www.nabble.com/I%27m-having-trouble-getting-an-ssl-client-programmed-in-java-tp17980660p17980660.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.

Reply via email to