Skip to content

Commit

Permalink
GH-1461: Fix X.509 tests issue happening on some execution environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Oct 18, 2023
1 parent 71cb086 commit a8824a7
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -17,6 +17,7 @@

import static org.eclipse.leshan.core.LwM2mId.OSCORE;

import java.net.InetSocketAddress;
import java.net.URI;
import java.security.PrivateKey;
import java.security.PublicKey;
Expand Down Expand Up @@ -436,11 +437,14 @@ public LeshanTestClientBuilder behind(ReverseProxy proxy) {
private URI getServerUri() {
LwM2mServerEndpoint endpoint = server.getEndpoint(protocolToUse);
URI serverUri = endpoint.getURI();
// we force usage of "localhost" as hostname to be sure that X.509 test works.
// see : https://github.com/eclipse-leshan/leshan/issues/1461#issuecomment-1631143202
if (proxy != null) {
// if server is behind a proxy we use its URI
return EndpointUriUtil.replaceAddress(serverUri, proxy.getClientSideProxyAddress());
return EndpointUriUtil.replaceAddress(serverUri,
new InetSocketAddress("localhost", proxy.getClientSideProxyAddress().getPort()));
} else {
return serverUri;
return EndpointUriUtil.replaceAddress(serverUri, new InetSocketAddress("localhost", serverUri.getPort()));
}
}
}

0 comments on commit a8824a7

Please sign in to comment.