• Post Reply Bookmark Topic Watch Topic
  • New Topic

What's problem with this SSL Socket??

 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code:
import java.io.*;
import java.net.*;
import javax.net.ssl.*;
//
// Example of an HTTPS server to illustrate SSL certificate and socket
public class HTTPSServerExample {
public static void main(String[] args) throws IOException {
//
// create an SSL socket using the factory and pick port 8080
SSLServerSocketFactory ssl=
(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
ServerSocket ss = ssl.createServerSocket(8081);
//
// loop forever
while (true) {
try {
//
// block waiting for client connection
Socket s = ss.accept();
System.out.println( "Client connection made" );
// get client request
BufferedReader in = new BufferedReader(
new InputStreamReader(s.getInputStream()));
System.out.println(in.readLine());
//
// make an HTML response
PrintWriter out = new PrintWriter( s.getOutputStream() );
out.println("<HTML><HEAD><TITLE>HTTPS Server Example</TITLE>" +
"</HEAD><BODY><H1>Hello World!</H1></BODY></HTML>\n");
//
// Close the stream and socket
out.close();
s.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
When i run it , it throw :
java.net.SocketException: no SSL Server Sockets
at javax.net.ssl.DefaultSSLServerSocketFactory.createServerSocket(DashoA6275)
at learningjce.HTTPSServerExample.main(HTTPSServerExample.java:25)
Exception in thread "main"
what's problem???thx!!!
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using J2SE 1.3, and if so, have you followed the JSSE installation instructions to the letter?
- Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!