Results 1 to 1 of 1
- 10-14-2008, 11:27 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 1
- Rep Power
- 0
SSL Server with authentication of clients
Hello, I am new in Java and I am programming SSL Server.
I need to authenticate the clients with valid certs and then save some information about them by CN.
Also I need to use as client socat. My problem is, that every java tutorial
is using only keytool, and also if I export the certificate, I couldn't connect.
I tryed this ddj.com/184404478 tutorial. I need something like this socat stdio openssl-connect:127.0.0.1:8080,cafile=ca.crt,cert=client.c rt,
but I always get
2008/10/14 23:09:26 socat[954] E SSL_connect(): error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
What should I do for verify success? This is the portion of my code:
private static ServerSocketFactory createServerSocketFactory(String type) {
if (type.equals("TLS")) {
SSLServerSocketFactory ssf = null;
try {
// set up key manager to do server authentication
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
KeyStore ks = KeyStore.getInstance("JKS");
char[] passphrase = "123456".toCharArray();
ks.load(new FileInputStream("testkeys"), passphrase);
kmf.init(ks, passphrase);
TrustManagerFactory tmf =
TrustManagerFactory.getInstance("SunX509");
tmf.init(ks);
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
ssf = ctx.getServerSocketFactory();
return ssf;
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
} // try
} else {
return ServerSocketFactory.getDefault();
} // if
return null;
} // createServerSocketFactory
And it is invoked from main function:
try {
ServerSocketFactory ssf = SecureTCPServer.createServerSocketFactory(type);
ServerSocket ss = ssf.createServerSocket(DEFAULT_PORT);
if (type.equals("TLS")) {
((SSLServerSocket) ss).setNeedClientAuth(true);
}
acceptConnections(ss);
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
Thanks very much for your support. (I have also a working client/server with keytool, but I need to use socat client from freshmeat.net/projects/socat , or just identify the clients with cafile/cert file).
Similar Threads
-
Integrated Windows Domian Authentication
By mahesh.komuravelli in forum Advanced JavaReplies: 1Last Post: 11-20-2009, 08:13 AM -
blocked between server and clients
By ibtehal in forum NetworkingReplies: 6Last Post: 07-17-2008, 12:30 AM -
530 5.7.0 Authentication Required - JavaMail gmail
By simon in forum Advanced JavaReplies: 1Last Post: 07-14-2007, 11:52 PM -
JavaMail:Authentication required error
By bbq in forum Advanced JavaReplies: 1Last Post: 07-05-2007, 04:16 AM -
Multple Clients
By samson in forum NetworkingReplies: 1Last Post: 04-04-2007, 06:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks