Results 1 to 2 of 2
  1. #1
    krishna11484 is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default JAVA TLS client application

    I have a AudioCodes SIP gateway, and I am writing a lightweight SIP client in JAVA, I got this working for TCP, however I am trying to implement TLS. I have the certificates, however I cannot find an example of how to use JAVA sockets to connect over TLS using external certificates, can somebody please point me in the right direction. Thank you.

    Below is what I have, I imported the root CA in the truststore using keytool,

    keytool -import -trustcacerts -alias caroot2 -file ca-root-cert.pem -keystore keystore.jks

    I get the following error:

    > javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

    Can somebody please help me ??

    Java Code:
        package atobtls;
        import javax.net.ssl.SSLSocket;
        import javax.net.ssl.SSLSocketFactory;
        import java.io.*;
        
        public class Atobtls {
            public
                    static
            void
                    main(String[] arstring) {
                try {
                    String truststorePath = "keystore.jks";
                    String truststorePass = "abc123";
                    
                    System.setProperty("javax.net.ssl.trustStore", truststorePath);
                    System.setProperty("javax.net.ssl.trustStorePassword", truststorePass);
        
                    SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
                    SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("192.168.217.1", 443);
        
                    InputStream inputstream = System.in;
                    InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
                    BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
        
                    OutputStream outputstream = sslsocket.getOutputStream();
                    OutputStreamWriter outputstreamwriter = new OutputStreamWriter(outputstream);
                    BufferedWriter bufferedwriter = new BufferedWriter(outputstreamwriter);
        
                    String string = "test";
                    
                        bufferedwriter.write(string + '\n');
                        bufferedwriter.flush();
                   
                } catch (Exception exception) {
                    exception.printStackTrace();
                }
            }
        }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: JAVA TLS client application

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Create Java Enterprise Application with Mobile Client
    By praveensingh18 in forum Advanced Java
    Replies: 2
    Last Post: 08-25-2012, 12:29 AM
  2. EJB Java Application Client jars needed
    By Fra in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 05-07-2012, 02:42 AM
  3. problems trying to call an EJB's method from a Java Application Client
    By ahmedbj in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 01-15-2012, 05:20 PM
  4. Suggestions on Multi Client Java Application
    By neofite in forum Advanced Java
    Replies: 3
    Last Post: 01-25-2011, 06:24 AM
  5. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 10:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •