2424import com .rabbitmq .stream .ChannelCustomizer ;
2525import com .rabbitmq .stream .ConfirmationHandler ;
2626import com .rabbitmq .stream .Environment ;
27+ import com .rabbitmq .stream .Host ;
2728import com .rabbitmq .stream .OffsetSpecification ;
2829import com .rabbitmq .stream .Producer ;
2930import com .rabbitmq .stream .StreamException ;
3435import io .netty .handler .ssl .SslHandler ;
3536import java .io .File ;
3637import java .io .FileInputStream ;
38+ import java .io .IOException ;
39+ import java .net .InetAddress ;
40+ import java .net .UnknownHostException ;
3741import java .nio .charset .Charset ;
3842import java .nio .charset .StandardCharsets ;
3943import java .nio .file .Files ;
@@ -106,7 +110,8 @@ static X509Certificate clientCertificate() throws Exception {
106110
107111 static String clientCertificateFile () {
108112 return System .getProperty (
109- "client.certificate" , "/tmp/tls-gen/basic/result/client_certificate.pem" );
113+ "client.certificate" ,
114+ "/tmp/tls-gen/basic/result/client_" + hostname () + "_certificate.pem" );
110115 }
111116
112117 static PrivateKey clientKey () throws Exception {
@@ -131,7 +136,8 @@ static PrivateKey loadPrivateKey(String filename) throws Exception {
131136 }
132137
133138 static String clientKeyFile () {
134- return System .getProperty ("client.key" , "/tmp/tls-gen/basic/result/client_key.pem" );
139+ return System .getProperty (
140+ "client.key" , "/tmp/tls-gen/basic/result/client_" + hostname () + "_key.pem" );
135141 }
136142
137143 static X509Certificate loadCertificate (String file ) throws Exception {
@@ -315,4 +321,16 @@ void clientShouldContainServerAdvertisedTlsPort() {
315321 Client client = cf .get (new ClientParameters ().sslContext (alwaysTrustSslContext ()));
316322 assertThat (client .serverAdvertisedPort ()).isEqualTo (Client .DEFAULT_TLS_PORT );
317323 }
324+
325+ private static String hostname () {
326+ try {
327+ return InetAddress .getLocalHost ().getHostName ();
328+ } catch (UnknownHostException e ) {
329+ try {
330+ return Host .hostname ();
331+ } catch (IOException ex ) {
332+ throw new RuntimeException (ex );
333+ }
334+ }
335+ }
318336}
0 commit comments