我更倾向于使这个SSL连接正常工作,但是如果有人能告诉我为什么我的applet触发'sslv3警报证书未知'错误会很好。我通过运行“openssl s_server”和(尝试)发现了这个错误使用我的Java客户端连接到它。我将包含该程序的源代码。我听说它可能缺少一个信任存储但我创建了一个并没有帮助。
public class first extends JApplet {
PrintWriter toServer = null;
BufferedReader fromServer = null;
public void init() {
System.setProperty("javax.net.ssl.keyStore", "javakeys");
System.setProperty("javax.net.ssl.keyStorePassword", "javakeys");
System.setProperty("javax.net.ssl.trustStore", "truststore.ts");
System.setProperty("javax.net.ssl.trustStorePassword", "javakeys");
try {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("localhost", 4000);
toServer = new PrintWriter(sslsocket.getOutputStream(), true);
toServer.println("Flystar\n\r");
InputStreamReader isr = new InputStreamReader(sslsocket.getInputStream());
fromServer = new BufferedReader(isr, 1);
JOptionPane.showMessageDialog( null, fromServer );
} catch (Exception exception) {
exception.printStackTrace();
}
// toServer.println("Flystar".getBytes());
}
public void paint(Graphics g) {
g.setColor( Color.red );
g.drawString("Welcome to Java!!", 50, 60 );
}
}
谢谢, -Roland
答案 0 :(得分:0)
“sslv3 alert certificate unknown”表示服务器的证书采用Java客户端无法理解的格式。