// JP opened flex table

Click to See Complete Forum and Search --> : Exception: serverkeys


babjava
May 13th, 2008, 01:05 AM
Hi All

I am going to develop a Https server.I got some may tips to develop a Https server.Now i have a code which is throws Exception.

Exception is . Exception: serverkeys (The system cannot find the file specified)

code is use for key is here :-




public ServerSocket getServer() throws Exception
{
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore), keystorepass);
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, keypassword);
SSLContext sslcontext = SSLContext.getInstance("SSLv3");
sslcontext.init(kmf.getKeyManagers(), null, null);
ServerSocketFactory ssf = sslcontext.getServerSocketFactory();
SSLServerSocket serversocket = (SSLServerSocket)ssf.createServerSocket(HTTPS_PORT);
return serversocket;
}




Plz help me

babjava
May 13th, 2008, 07:29 AM
Help me it's a urgent

dlorde
May 13th, 2008, 11:38 AM
Can you paste up the full text of the error message and the stack trace (use copy & paste), and post the code that uses serverkeys.

It's not our problem that it's urgent, and if you provide better information you will probably get a quicker answer.

All truths are easy to understand once they are discovered; the point is to discover them...
G. Galilie

babjava
May 14th, 2008, 12:27 AM
Hi

This is a error

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ProcessConnection cannot be resolved to a type
ProcessConnection cannot be resolved to a type

at HttpsServer.run(HttpsServer.java:52)
at HttpsServer.main(HttpsServer.java:62)

Exception: serverkeys (The system cannot find the file specified)

And code is here


import java.io.*;
import java.net.*;
import javax.net.*;
import javax.net.ssl.*;
import java.security.*;
import java.util.StringTokenizer;

/**
* This class implements a multithreaded simple HTTPS
* server that supports the GET request method.
* It listens on port 44, waits client requests
* and serves documents.
*/

public class HttpsServer {

String keystore = "serverkeys";
char keystorepass[] = "hellothere".toCharArray();
char keypassword[] = "hiagain".toCharArray();

// The port number which the server will be listening on
public static final int HTTPS_PORT = 443;


public ServerSocket getServer() throws Exception {

KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(keystore), keystorepass);
KeyManagerFactory kmf =
KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, keypassword);
SSLContext sslcontext =
SSLContext.getInstance("SSLv3");
sslcontext.init(kmf.getKeyManagers(), null, null);
ServerSocketFactory ssf =
sslcontext.getServerSocketFactory();
SSLServerSocket serversocket = (SSLServerSocket)
ssf.createServerSocket(HTTPS_PORT);
return serversocket;

}


// multi-threading -- create a new connection
// for each request
public void run() {
ServerSocket listen;
try {
listen = getServer();
while(true) {
Socket client = listen.accept();
// ProcessConnection cc = new ProcessConnection(client);
}
} catch(Exception e) {
System.out.println("Exception: "+e.getMessage());
}
}

// main program
public static void main(String argv[]) throws Exception {
HttpsServer https = new HttpsServer();
https.run();
}
}

dlorde
May 14th, 2008, 08:08 AM
You need to put the ProcessConnection class on the classpath, and a keystore file called 'serverkeys' in the working directory.

Before you ask, I don't know what the ProcessConnection class is, it's not part of the SDK.

It is not knowledge, but the act of learning, not possession, but the act of getting there which generates the greatest satisfaction...
F. Gauss

//JP added flex table