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

    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:

    > java.lang.RuntimeException: Unexpected error: the trustAnchors parameter must be non-empty

    Can somebody please help me ??

    Java Code:
        package atobtls;
        public class Atobtls {
                    main(String[] arstring) {
                try {
                    String truststorePath = "keystore.jks";
                    String truststorePass = "abc123";
                    System.setProperty("", truststorePath);
                    System.setProperty("", truststorePass);
                    SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
                    SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("", 443);
                    InputStream inputstream =;
                    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');
                } catch (Exception exception) {

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Rep Power

    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