|
16 | 16 | package com.rabbitmq.client.test.ssl; |
17 | 17 |
|
18 | 18 | import com.rabbitmq.client.Address; |
| 19 | +import com.rabbitmq.client.Connection; |
19 | 20 | import com.rabbitmq.client.ConnectionFactory; |
20 | 21 | import com.rabbitmq.client.test.TestUtils; |
| 22 | +import com.rabbitmq.tools.Host; |
21 | 23 | import org.junit.BeforeClass; |
22 | 24 | import org.junit.Test; |
23 | 25 | import org.junit.runner.RunWith; |
|
34 | 36 | import static com.rabbitmq.client.test.TestUtils.getSSLContext; |
35 | 37 | import static java.util.Collections.singletonList; |
36 | 38 | import static org.junit.Assert.assertNotNull; |
| 39 | +import static org.junit.Assert.assertTrue; |
37 | 40 | import static org.junit.Assert.fail; |
38 | 41 |
|
39 | 42 | @RunWith(Parameterized.class) |
@@ -107,4 +110,14 @@ public void hostnameVerificationFailsBecauseCertificateNotIssuedForLoopbackInter |
107 | 110 | () -> singletonList(new Address("127.0.0.1", ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT))); |
108 | 111 | fail("The server certificate isn't issued for 127.0.0.1, the TLS handshake should have failed"); |
109 | 112 | } |
| 113 | + |
| 114 | + public void hostnameVerificationSucceeds() throws Exception { |
| 115 | + ConnectionFactory connectionFactory = TestUtils.connectionFactory(); |
| 116 | + connectionFactory.useSslProtocol(sslContext); |
| 117 | + customizer.accept(connectionFactory); |
| 118 | + Connection conn = connectionFactory.newConnection( |
| 119 | + () -> singletonList(new Address(Host.systemHostname(), ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT))); |
| 120 | + assertTrue(conn.isOpen()); |
| 121 | + conn.close(); |
| 122 | + } |
110 | 123 | } |
0 commit comments