使用下面的代码来测试在RMI SSL连接:Java RMI SSL是否存在密钥库/信任库错误?
public class HelloImpl extends UnicastRemoteObject implements Hello {
public HelloImpl() throws RemoteException {
super(0, new SslRMIClientSocketFactory(), new SslRMIServerSocketFactory());
}
public String sayHello() {
return "Hello World!";
}
public static void main(String args[]) throws Exception {
// Get reference to the RMI registry running on port 3000 in the local host
Registry registry = LocateRegistry.getRegistry(null, 3000);
// Bind this object instance to the name "HelloServer"
HelloImpl obj = new HelloImpl();
registry.bind("HelloServer", obj);
System.out.println("HelloServer bound in registry");
}
}
其余部分是相当普通的(使用了一些代码从这里:http://blogs.oracle.com/lmalventosa/entry/using_the_ssl_tls_based),基本上试图做的仅服务器身份验证以获取SSL加工。然而,得到这个唠叨错误:
RMI RenewClean-[146.169.51.86:60013,[email protected]], READ: TLSv1 Alert, length = 2
RMI RenewClean-[146.169.51.86:60013,[email protected]], RECV TLSv1 ALERT: fatal, bad_certificate
RMI RenewClean-[146.169.51.86:60013,[email protected]], called closeSocket()
RMI RenewClean-[146.169.51.86:60013,[email protected]], Exception while waiting for close javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
RMI RenewClean-[146.169.51.86:60013,[email protected]], handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
它从调试转储,他们试图做一个握手,至于交换对称密钥去,但在这件事上失败,对于一些无法解释的原因出现
。在编译期间,我们指定存储在文件夹中的信任存储:
# $ java -Djavax.net.ssl.trustStore=truststore -Djavax.net.ssl.trustStorePassword=trustword HelloClient
任何帮助非常感谢!