我需要写一个简单的程序的工作,并如下:

  1. 读配置文件
  2. 连接到一个服务器群
  3. 建立一个ssl插座
  4. 拉信息形式的服务器的x509证,到期日期和名为现在
  5. 电子邮件的报告时对其做

项目3和项目4的事,我有了坏的运气研究/googleing我不知道java好吧,在所有由于1.2 2001年左右

有帮助吗?

解决方案 2

我找到了一个代码snipit,告诉我什么我需要知道的关于在java http://www.exampledepot.com/egs/javax.net.ssl/GetCert.html

这里是:

try {

    // Create the client socket
    int port = 443;
    String hostname = "hostname";
    SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
    SSLSocket socket = (SSLSocket)factory.createSocket(hostname, port);

    // Connect to the server
    socket.startHandshake();

    // Retrieve the server's certificate chain
    java.security.cert.Certificate[] serverCerts =
        socket.getSession().getPeerCertificates();

    // Close the socket
    socket.close();
} catch (SSLPeerUnverifiedException e) {
} catch (IOException e) {
} catch (java.security.cert.CertificateEncodingException e) {   
}

其他提示

一个详细,而且在整个指南有关的内层的Java密码扩展现在神谕的网站,以及: http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top