1- import java .net .InetSocketAddress ;
21import java .net .Socket ;
32import java .nio .ByteBuffer ;
43import javax .net .SocketFactory ;
@@ -25,9 +24,6 @@ public void testSSLEngineEndpointIdSetNull() throws Exception {
2524 sslEngine .unwrap (null , null , 0 , 0 ); // $hasUnsafeCertTrust
2625 }
2726
28- /**
29- * Test the endpoint identification of SSL engine is set to null
30- */
3127 public void testSSLEngineEndpointIdSetEmpty () throws Exception {
3228 SSLContext sslContext = SSLContext .getInstance ("TLS" );
3329 SSLEngine sslEngine = sslContext .createSSLEngine ();
@@ -39,9 +35,6 @@ public void testSSLEngineEndpointIdSetEmpty() throws Exception {
3935 sslEngine .unwrap (null , null , 0 , 0 ); // $hasUnsafeCertTrust
4036 }
4137
42- /**
43- * Test the endpoint identification of SSL engine is set to HTTPS
44- */
4538 public void testSSLEngineEndpointIdSafe () throws Exception {
4639 SSLContext sslContext = SSLContext .getInstance ("TLS" );
4740 SSLEngine sslEngine = sslContext .createSSLEngine ();
@@ -53,9 +46,6 @@ public void testSSLEngineEndpointIdSafe() throws Exception {
5346 sslEngine .unwrap (null , null , 0 , 0 ); // Safe
5447 }
5548
56- /**
57- * Test the endpoint identification of SSL engine is set to HTTPS
58- */
5949 public void testSSLEngineInServerMode () throws Exception {
6050 SSLContext sslContext = SSLContext .getInstance ("TLS" );
6151 SSLEngine sslEngine = sslContext .createSSLEngine ();
@@ -65,95 +55,64 @@ public void testSSLEngineInServerMode() throws Exception {
6555 sslEngine .unwrap (null , null , 0 , 0 ); // Safe
6656 }
6757
68- /**
69- * Test the endpoint identification of SSL socket is not set
70- */
71- public void testSSLSocketImmediatelyConnects () throws Exception {
72- SSLContext sslContext = SSLContext .getInstance ("TLS" );
73- SocketFactory socketFactory = sslContext .getSocketFactory ();
74- SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 ); // $hasUnsafeCertTrust
75- }
76-
77- /**
78- * Test the endpoint identification of SSL socket is not set
79- */
8058 public void testSSLSocketEndpointIdNotSet () throws Exception {
8159 SSLContext sslContext = SSLContext .getInstance ("TLS" );
8260 SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
8361 SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
84- socket .connect ( new InetSocketAddress ( "www.example.com" , 443 ) ); // $hasUnsafeCertTrust
62+ socket .getOutputStream ( ); // $hasUnsafeCertTrust
8563 }
8664
87- /**
88- * Test the endpoint identification of SSL socket is set to null
89- */
9065 public void testSSLSocketEndpointIdSetNull () throws Exception {
9166 SSLContext sslContext = SSLContext .getInstance ("TLS" );
9267 SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
9368 SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
9469 SSLParameters sslParameters = socket .getSSLParameters ();
9570 sslParameters .setEndpointIdentificationAlgorithm (null );
9671 socket .setSSLParameters (sslParameters );
97- socket .connect ( new InetSocketAddress ( "www.example.com" , 443 ) ); // $hasUnsafeCertTrust
72+ socket .getOutputStream ( ); // $hasUnsafeCertTrust
9873 }
9974
100- /**
101- * Test the endpoint identification of SSL socket is set to empty
102- */
10375 public void testSSLSocketEndpointIdSetEmpty () throws Exception {
10476 SSLContext sslContext = SSLContext .getInstance ("TLS" );
10577 SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
10678 SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
10779 SSLParameters sslParameters = socket .getSSLParameters ();
10880 sslParameters .setEndpointIdentificationAlgorithm ("" );
10981 socket .setSSLParameters (sslParameters );
110- socket .connect ( new InetSocketAddress ( "www.example.com" , 443 ) ); // $hasUnsafeCertTrust
82+ socket .getOutputStream ( ); // $hasUnsafeCertTrust
11183 }
11284
113- /**
114- * Test the endpoint identification of SSL socket is not set
115- */
11685 public void testSSLSocketEndpointIdAfterConnecting () throws Exception {
11786 SSLContext sslContext = SSLContext .getInstance ("TLS" );
11887 SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
119- SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 ); // $hasUnsafeCertTrust
88+ SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
89+ socket .getOutputStream (); // $hasUnsafeCertTrust
12090 SSLParameters sslParameters = socket .getSSLParameters ();
12191 sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
12292 socket .setSSLParameters (sslParameters );
12393 }
12494
125- /**
126- * Test the endpoint identification of SSL socket is not set
127- */
12895 public void testSSLSocketEndpointIdSafe () throws Exception {
12996 SSLContext sslContext = SSLContext .getInstance ("TLS" );
13097 SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
13198 SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
13299 SSLParameters sslParameters = socket .getSSLParameters ();
133100 sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
134101 socket .setSSLParameters (sslParameters );
135- socket .connect ( new InetSocketAddress ( "www.example.com" , 443 ) ); // Safe
102+ socket .getOutputStream ( ); // Safe
136103 }
137104
138- /**
139- * Test the endpoint identification of regular socket is not set
140- */
141105 public void testSocketEndpointIdNotSet () throws Exception {
142106 SocketFactory socketFactory = SocketFactory .getDefault ();
143- Socket socket = socketFactory .createSocket ("www.example.com" , 80 ); // Safe
107+ Socket socket = socketFactory .createSocket ("www.example.com" , 80 );
108+ socket .getOutputStream (); // Safe
144109 }
145110
146- /**
147- * Test the enableHostnameVerification of RabbitMQConnectionFactory is not set
148- */
149111 public void testRabbitMQFactoryEnableHostnameVerificationNotSet () throws Exception {
150112 ConnectionFactory connectionFactory = new ConnectionFactory ();
151113 connectionFactory .useSslProtocol (); // $hasUnsafeCertTrust
152114 }
153115
154- /**
155- * Test the enableHostnameVerification of RabbitMQConnectionFactory is not set
156- */
157116 public void testRabbitMQFactorySafe () throws Exception {
158117 ConnectionFactory connectionFactory = new ConnectionFactory ();
159118 connectionFactory .useSslProtocol (); // Safe
0 commit comments