aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes What's problem with this SSL Socket?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "What Watch "What New topic
Author

What's problem with this SSL Socket??

Javan Li
Ranch Hand

Joined: Jul 24, 2002
Posts: 84
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

Joined: Apr 20, 2000
Posts: 3252
Are you using J2SE 1.3, and if so, have you followed the JSSE installation instructions to the letter?
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's problem with this SSL Socket??
 
Similar Threads
outputting html content to the server
web server
regarding https connectivity
Problem while connecting to Servlet
How to write to the servlet with standalone application