Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Getting "javax.net.ssl.SSLException" while writing SSL socket program

  1. #1
    Join Date
    Mar 2009
    Thanked 2 Times in 2 Posts

    Default Getting "javax.net.ssl.SSLException" while writing SSL socket program

    Hello, I am a begginer in programimg and I programmed the chat with SSL sockets. I created the certificate via tutorial on this website: Installing and Configuring SSL Support . I use IDE NetBeans and I would like to know the place/folder where the certificate has to be saved. Could you tell me in detail the procedure in Netbeans.
    But momentarily it doesn't work because of the error: javax.net.ssl.SSLException: No available certificate or key corresponds to the SSL cipher suites which are enabled.
    This is the code of server:
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.net.ssl.SSLServerSocket;
    import javax.net.ssl.SSLServerSocketFactory;
    import javax.net.ssl.SSLSocket;
     * @author Lolek
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            try {
                int port = 5000;
                SSLServerSocketFactory serverSocketFactory = null;
                SSLServerSocket serverSocket = null;
                SSLSocket socket = null;
                serverSocketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
                serverSocket = (SSLServerSocket) serverSocketFactory.createServerSocket(port);
                while (true) {
                    socket = (SSLSocket) serverSocket.accept();
                    ChatHandler handler = new ChatHandler(socket);
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    class ChatHandler extends Thread
         static ArrayList handlers = new ArrayList(10);
         private SSLSocket socket;
         private BufferedReader read;
         private BufferedWriter write;
         public ChatHandler(SSLSocket socket)
            try {
                this.socket = socket;
                this.read = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                this.write = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            } catch (IOException ex) {
                Logger.getLogger(ChatHandler.class.getName()).log(Level.SEVERE, null, ex);
         public void run(){
         String line=null;
    	synchronized(handlers) {
    	try {
    	    while(!(line = read.readLine()).equalsIgnoreCase("/q")) {            
                    for(int i = 0; i < handlers.size(); i++) {	
    			synchronized(handlers) {
    		            ChatHandler handler = (ChatHandler)handlers.get(i);                            
    	} catch(IOException ioe) {
    	} finally {
    	    try {
    	    } catch(IOException ioe) {
    	    } finally {
    		synchronized(handlers) {

  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    United Kingdom
    My Mood
    Thanked 294 Times in 227 Posts
    Blog Entries

    Default Re: Start SSL socket

    Hello Koren3,

    I have no experience with this myself. Do these links help you?

    Advanced Web Service Interoperability - NetBeans IDE 6.0/6.1 Tutorial

    Transport Security (SSL) Workaround (The WSIT Tutorial) - Sun Microsystems

    StoKen Tips and Tricks: HOWTO: setup Java to trust unsigned SSL CERTs
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to Create a server socket to listen for incoming connections?
    By JavaPF in forum Java Networking Tutorials
    Replies: 3
    Last Post: October 28th, 2011, 09:02 AM
  2. How should i write and compile java with Ubuntu?
    By Talk Binary in forum Java IDEs
    Replies: 19
    Last Post: May 7th, 2009, 05:29 AM
  3. [SOLVED] Java code to embedding xml tags at start and end of file
    By John in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 30th, 2009, 03:02 PM
  4. Replies: 2
    Last Post: October 7th, 2008, 11:03 PM
  5. Best way to learn java for beginners
    By JavaPF in forum The Cafe
    Replies: 0
    Last Post: May 8th, 2008, 04:37 AM