Código:
import java.net.*; import java.io.*; import javax.net.ServerSocketFactory; import java.net.ServerSocket; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLServerSocketFactory; public class serverSSL { public static void main( String args[] ) { ServerSocket server = (ServerSocket)null; try { ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault(); server = ssocketFactory.createServerSocket(4321); while(true){ Socket client = server.accept(); InputStream aux = client.getInputStream(); DataInputStream flujo = new DataInputStream( aux ); System.out.println(flujo.readUTF()); OutputStream bufferSalida = client.getOutputStream(); DataOutputStream datos = new DataOutputStream(bufferSalida); datos.writeUTF("hola"); } } catch(IOException e) { e.printStackTrace(); } } }
Para ejecutarlo hago:
Código:
¿Qué estoy haciendo mal? soy incapaz de verlo!ubuntu@ubuntu:~/pruebasJava$ keytool -genkey -keystore mySrvKeystore -keyalg RSA Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]: What is the name of your organization? [Unknown]: What is the name of your City or Locality? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit? [Unknown]: Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct? [no]: y Enter key password for <mykey> (RETURN if same as keystore password): ubuntu@ubuntu:~/pruebasJava$ java -Djavax.net.ssl.trustStore=mySrvKeystore -Djavax.net.ssl.trustStorePassword=123456 serverSSL javax.net.ssl.SSLException: No available certificate or key corresponds to the SSL cipher suites which are enabled. at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.checkEnabledSuites(SSLServerSocketImpl.java:310) at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.accept(SSLServerSocketImpl.java:255) at serverSSL.main(serverSSL.java:18)
gracias!