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); handler.start(); } } 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) { handlers.add(this); } try { while(!(line = read.readLine()).equalsIgnoreCase("/q")) { for(int i = 0; i < handlers.size(); i++) { synchronized(handlers) { ChatHandler handler = (ChatHandler)handlers.get(i); handler.write.write(line); handler.write.newLine(); handler.write.flush(); } } } } catch(IOException ioe) { ioe.printStackTrace(); } finally { try { read.close(); write.close(); socket.close(); } catch(IOException ioe) { } finally { synchronized(handlers) { handlers.remove(this); } } } } }