Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

no available certificate corresponds to SSL cipher suites which are enable

843811Jun 11 2004 — edited Dec 7 2004
/* i'm try run a example how this
the client is this
*/
import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class TLSEchoClient{
public static void main(String argv[])throws Exception {
SSLSocketFactory factory=
(SSLSocketFactory)
SSLSocketFactory.getDefault();

Socket sock=new Socket("127.0.0.1",8189);
SSLSocket ssl=(SSLSocket)factory.createSocket(sock,argv[0],8189,true);

OutputStream out=ssl.getOutputStream();

DataOutputStream fout=new DataOutputStream(out);

fout.writeUTF("TEST");

}
}
/*
the server is this
*/



import java.io.*;
import java.net.*;
import javax.net.ssl.*;

public class TLSEchoServer{

public static int MYECHOPORT= 8189;

public static void main(String argv[])throws Exception {
SSLServerSocketFactory factory=
(SSLServerSocketFactory)
SSLServerSocketFactory.getDefault();

SSLServerSocket sslSocket=
(SSLServerSocket)
factory.createServerSocket(MYECHOPORT);

while(true){
Socket incoming = sslSocket.accept();
InputStream in=incoming.getInputStream();
DataInputStream fin=new DataInputStream(in);
System.out.println(fin.readUTF());
}

}

}

/*
create the certfile

keytool -genkey -keystore mykeystore -alias myalias -keypass mykey
keytool -export -alias myalias -keystore mykeystore -file mycertfile.cer
keytool -import -alias myalias -keystore mytruststore -file mycertfile.cer

for run this example the commands

java -Djavax.net.ssl.keyStore=mykeystore -Djavax.net.ssl.keyStorePassword=mypassword TLSEchoServer
java -Djavax.net.ssl.keyStore=mykeystore -Djavax.net.ssl.keyStorePassword=mypassword TLSEchoClient
*/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2005
Added on Jun 11 2004
2 comments
101 views