Skip to content

Commit d15546d

Browse files
authored
Set exposed port of TLS implementation instead first found (#75)
1 parent 7c60fa1 commit d15546d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/java/de/rub/nds/tls/subject/docker/DockerTlsServerInstance.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class DockerTlsServerInstance extends DockerTlsInstance {
3131
private final String additionalParameters;
3232
private final boolean parallelize;
3333
private final boolean insecureConnection;
34+
private ExposedPort exposedImplementationPort;
3435

3536
public DockerTlsServerInstance(String containerName, ParameterProfile profile, ImageProperties imageProperties,
3637
String version, boolean autoRemove, HostInfo hostInfo, String additionalParameters, boolean parallelize,
@@ -59,10 +60,10 @@ protected CreateContainerCmd prepareCreateContainerCmd(CreateContainerCmd cmd) {
5960
} else {
6061
host = hostInfo.getHostname();
6162
}
62-
return super.prepareCreateContainerCmd(cmd)
63-
.withCmd(parameterProfile.toParameters(host, hostInfo.getPort(), imageProperties, additionalParameters,
64-
parallelize, insecureConnection))
65-
.withExposedPorts(new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol()));
63+
exposedImplementationPort = new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol());
64+
return super.prepareCreateContainerCmd(cmd).withCmd(parameterProfile.toParameters(host, hostInfo.getPort(),
65+
imageProperties, additionalParameters, parallelize, insecureConnection))
66+
.withExposedPorts(exposedImplementationPort);
6667
}
6768

6869
@Override
@@ -84,7 +85,12 @@ public void updateInstancePort() {
8485
throw new IllegalStateException(
8586
"Cannot retrieve InstacePort, Network not properly configured for container with ID:" + getId());
8687
}
87-
Binding[] binding = networkSettings.getPorts().getBindings().values().iterator().next();
88+
if (exposedImplementationPort == null) {
89+
throw new IllegalStateException(
90+
"Unable to update port - no exposed port set for container with ID:" + getId());
91+
}
92+
93+
Binding[] binding = networkSettings.getPorts().getBindings().get(exposedImplementationPort);
8894
if (binding != null) {
8995
// only update if port mapping was necessary
9096
port = Integer.valueOf(binding[0].getHostPortSpec());

0 commit comments

Comments
 (0)