@@ -19,7 +19,7 @@ public void testSSLEngineEndpointIdSetNull() throws java.security.NoSuchAlgorith
19
19
SSLParameters sslParameters = sslEngine .getSSLParameters ();
20
20
sslParameters .setEndpointIdentificationAlgorithm (null );
21
21
sslEngine .setSSLParameters (sslParameters );
22
- sslEngine .getSession ();
22
+ sslEngine .getSession (); // $hasUnsafeCertTrust
23
23
}
24
24
25
25
/**
@@ -28,7 +28,7 @@ public void testSSLEngineEndpointIdSetNull() throws java.security.NoSuchAlgorith
28
28
public void testSSLEngineEndpointIdNotSet () throws java .security .NoSuchAlgorithmException {
29
29
SSLContext sslContext = SSLContext .getInstance ("TLS" );
30
30
SSLEngine sslEngine = sslContext .createSSLEngine ();
31
- sslEngine .getSession ();
31
+ sslEngine .getSession (); // $hasUnsafeCertTrust
32
32
}
33
33
34
34
/**
@@ -40,7 +40,7 @@ public void testSSLEngineEndpointIdSafe() throws java.security.NoSuchAlgorithmEx
40
40
SSLParameters sslParameters = sslEngine .getSSLParameters ();
41
41
sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
42
42
sslEngine .setSSLParameters (sslParameters );
43
- sslEngine .getSession ();
43
+ sslEngine .getSession (); // Safe
44
44
}
45
45
46
46
/**
@@ -49,8 +49,8 @@ public void testSSLEngineEndpointIdSafe() throws java.security.NoSuchAlgorithmEx
49
49
public void testSSLSocketImmediatelyConnects ()
50
50
throws java .security .NoSuchAlgorithmException , java .io .IOException {
51
51
SSLContext sslContext = SSLContext .getInstance ("TLS" );
52
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
53
- SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 );
52
+ SocketFactory socketFactory = sslContext .getSocketFactory ();
53
+ SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 ); // $hasUnsafeCertTrust
54
54
}
55
55
56
56
/**
@@ -59,9 +59,9 @@ public void testSSLSocketImmediatelyConnects()
59
59
public void testSSLSocketEndpointIdNotSet ()
60
60
throws java .security .NoSuchAlgorithmException , java .io .IOException {
61
61
SSLContext sslContext = SSLContext .getInstance ("TLS" );
62
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
62
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
63
63
SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
64
- socket .connect (new InetSocketAddress ("www.example.com" , 443 ));
64
+ socket .connect (new InetSocketAddress ("www.example.com" , 443 )); // $hasUnsafeCertTrust
65
65
}
66
66
67
67
/**
@@ -70,12 +70,12 @@ public void testSSLSocketEndpointIdNotSet()
70
70
public void testSSLSocketEndpointIdSetNull ()
71
71
throws java .security .NoSuchAlgorithmException , java .io .IOException {
72
72
SSLContext sslContext = SSLContext .getInstance ("TLS" );
73
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
73
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
74
74
SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
75
75
SSLParameters sslParameters = socket .getSSLParameters ();
76
76
sslParameters .setEndpointIdentificationAlgorithm (null );
77
77
socket .setSSLParameters (sslParameters );
78
- socket .connect (new InetSocketAddress ("www.example.com" , 443 ));
78
+ socket .connect (new InetSocketAddress ("www.example.com" , 443 )); // $hasUnsafeCertTrust
79
79
}
80
80
81
81
/**
@@ -84,12 +84,12 @@ public void testSSLSocketEndpointIdSetNull()
84
84
public void testSSLSocketEndpointIdSetEmpty ()
85
85
throws java .security .NoSuchAlgorithmException , java .io .IOException {
86
86
SSLContext sslContext = SSLContext .getInstance ("TLS" );
87
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
87
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
88
88
SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
89
89
SSLParameters sslParameters = socket .getSSLParameters ();
90
90
sslParameters .setEndpointIdentificationAlgorithm ("" );
91
91
socket .setSSLParameters (sslParameters );
92
- socket .connect (new InetSocketAddress ("www.example.com" , 443 ));
92
+ socket .connect (new InetSocketAddress ("www.example.com" , 443 )); // $hasUnsafeCertTrust
93
93
}
94
94
95
95
/**
@@ -98,8 +98,8 @@ public void testSSLSocketEndpointIdSetEmpty()
98
98
public void testSSLSocketEndpointIdAfterConnecting ()
99
99
throws java .security .NoSuchAlgorithmException , java .io .IOException {
100
100
SSLContext sslContext = SSLContext .getInstance ("TLS" );
101
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
102
- SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 );
101
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
102
+ SSLSocket socket = (SSLSocket ) socketFactory .createSocket ("www.example.com" , 443 ); // $hasUnsafeCertTrust
103
103
SSLParameters sslParameters = socket .getSSLParameters ();
104
104
sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
105
105
socket .setSSLParameters (sslParameters );
@@ -111,36 +111,36 @@ public void testSSLSocketEndpointIdAfterConnecting()
111
111
public void testSSLSocketEndpointIdSafe ()
112
112
throws java .security .NoSuchAlgorithmException , java .io .IOException {
113
113
SSLContext sslContext = SSLContext .getInstance ("TLS" );
114
- final SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
114
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
115
115
SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
116
116
SSLParameters sslParameters = socket .getSSLParameters ();
117
117
sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
118
118
socket .setSSLParameters (sslParameters );
119
- socket .connect (new InetSocketAddress ("www.example.com" , 443 ));
119
+ socket .connect (new InetSocketAddress ("www.example.com" , 443 )); // Safe
120
120
}
121
121
122
122
/**
123
123
* Test the endpoint identification of regular socket is not set
124
124
*/
125
125
public void testSocketEndpointIdNotSet () throws java .io .IOException {
126
126
SocketFactory socketFactory = SocketFactory .getDefault ();
127
- Socket socket = socketFactory .createSocket ("www.example.com" , 80 );
127
+ Socket socket = socketFactory .createSocket ("www.example.com" , 80 ); // Safe
128
128
}
129
129
130
130
/**
131
131
* Test the enableHostnameVerification of RabbitMQConnectionFactory is not set
132
132
*/
133
133
public void testRabbitMQFactoryEnableHostnameVerificationNotSet () throws Exception {
134
134
ConnectionFactory connectionFactory = new ConnectionFactory ();
135
- connectionFactory .useSslProtocol ();
135
+ connectionFactory .useSslProtocol (); // $hasUnsafeCertTrust
136
136
}
137
137
138
138
/**
139
139
* Test the enableHostnameVerification of RabbitMQConnectionFactory is not set
140
140
*/
141
141
public void testRabbitMQFactorySafe () throws Exception {
142
142
ConnectionFactory connectionFactory = new ConnectionFactory ();
143
- connectionFactory .useSslProtocol ();
143
+ connectionFactory .useSslProtocol (); // Safe
144
144
connectionFactory .enableHostnameVerification ();
145
145
}
146
146
}
0 commit comments