|
89 | 89 | public void testGetSetEnabledProtocols(); |
90 | 90 | public void testClientServerThreaded(); |
91 | 91 | public void testPreConsumedSocket(); |
| 92 | + public void testCreateSocketNullHost(); |
92 | 93 | public void testEnableSessionCreation(); |
93 | 94 | public void testSetUseClientMode(); |
94 | 95 | public void testGetSSLParameters(); |
@@ -530,6 +531,36 @@ public Void call() throws Exception { |
530 | 531 | System.out.println("\t... passed"); |
531 | 532 | } |
532 | 533 |
|
| 534 | + @Test |
| 535 | + public void testCreateSocketNullHost() throws Exception { |
| 536 | + |
| 537 | + System.out.print("\tcreateSocket(null host)"); |
| 538 | + |
| 539 | + /* create new CTX */ |
| 540 | + this.ctx = tf.createSSLContext("TLS", ctxProvider); |
| 541 | + |
| 542 | + /* create new ServerSocket first to get ephemeral port */ |
| 543 | + ServerSocket ss = new ServerSocket(0); |
| 544 | + |
| 545 | + /* create new Socket, connect() to server */ |
| 546 | + Socket cs = new Socket(); |
| 547 | + cs.connect(new InetSocketAddress(ss.getLocalPort())); |
| 548 | + |
| 549 | + /* accept client connection, normal java.net.Socket */ |
| 550 | + final Socket socket = ss.accept(); |
| 551 | + |
| 552 | + /* Try to convert client Socket to SSLSocket, with null hostname. |
| 553 | + * This should not throw any Exceptions, null host is ok. */ |
| 554 | + SSLSocket ssc = (SSLSocket)ctx.getSocketFactory().createSocket( |
| 555 | + cs, null, cs.getPort(), false); |
| 556 | + |
| 557 | + ssc.close(); |
| 558 | + cs.close(); |
| 559 | + socket.close(); |
| 560 | + ss.close(); |
| 561 | + |
| 562 | + System.out.println("\t\t... passed"); |
| 563 | + } |
533 | 564 |
|
534 | 565 | @Test |
535 | 566 | public void testEnableSessionCreation() throws Exception { |
|
0 commit comments