Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
SslSocketInfo.java - SSL Socket Information
How to get more information about the SSL Socket object? It is created as "SSLSocketFactory.createSocket()".
✍: FYIcenter
If you created a URL object with "new java.net.URL(...)",
you can use the following sample Java code to get more information about the URL object:
// Copyright (c) FYIcenter.com
import java.net.*;
import java.io.*;
import javax.net.ssl.*;
public class SslSocketInfo {
public static void main(String[] args) throws Exception {
String host = "www.oracle.com";
SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket)factory.createSocket(host, 443);
socket.startHandshake();
System.out.println("SSL Socket Information");
System.out.println(" Class name: "+socket.getClass().getName());
System.out.println(" Remote address = "+socket.getInetAddress());
System.out.println(" Remote port = "+socket.getPort());
System.out.println(" Local socket address = "+socket.getLocalSocketAddress());
System.out.println(" Local address = "+socket.getLocalAddress().toString());
System.out.println(" Local port = "+socket.getLocalPort());
System.out.println(" Need client authentication = "+socket.getNeedClientAuth());
SSLSession session = socket.getSession();
System.out.println(" Cipher suite = "+session.getCipherSuite());
System.out.println(" Protocol = "+session.getProtocol());
socket.close();
}
}
You can compile and run the above example in a command window:
\fyicenter>\local\jdk-1.8.0\bin\javac SslSocketInfo.java \fyicenter>\local\jdk-1.8.0\bin\java SslSocketInfo SSL Socket Information Class name: sun.security.ssl.SSLSocketImpl Remote address = www.oracle.com/23.203.120.118 Remote port = 443 Local socket address = /192.168.1.17:52840 Local address = /192.168.1.17 Local port = 52840 Need client authentication = false Cipher suite = TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 Protocol = TLSv1.2
The output confirms that:
⇒ SslCipherList.java - SSL Cipher List
⇐ SslSocketClient.java - SSL Socket Client Example
2018-03-31, ∼2519🔥, 0💬
Popular Posts:
What Is jtds-1.2.2.jar? jtds-1.2.2.jar is the JAR files of jTDS Java library 1.2.2, which is a JDBC ...
JDK 11 java.smartcardio.jmod is the JMOD file for JDK 11 Smartcardio module. JDK 11 Smart Card IO mo...
JDK 17 jdk.jlink.jmod is the JMOD file for JDK 17 JLink tool, which can be invoked by the "jlink" co...
What Is javaws.jar in JRE (Java Runtime Environment) 8? javaws.jar in JRE (Java Runtime Environment)...
JDK 17 java.sql.jmod is the JMOD file for JDK 17 SQL (Structured Query Language) module. JDK 17 SQL ...