diff --git a/integration-tests/cucumber-tests-platform-smartmetering/pom.xml b/integration-tests/cucumber-tests-platform-smartmetering/pom.xml index ce5d9b3b075..e090a3fe9d0 100644 --- a/integration-tests/cucumber-tests-platform-smartmetering/pom.xml +++ b/integration-tests/cucumber-tests-platform-smartmetering/pom.xml @@ -20,7 +20,7 @@ SPDX-License-Identifier: Apache-2.0 - 4.0.3 + 4.0.5 cucumber-tests-platform-smartmetering diff --git a/integration-tests/cucumber-tests-platform-smartmetering/src/main/assembly/test-jar-with-dependencies.xml b/integration-tests/cucumber-tests-platform-smartmetering/src/main/assembly/test-jar-with-dependencies.xml index e033a48dfea..9c79e63d36f 100644 --- a/integration-tests/cucumber-tests-platform-smartmetering/src/main/assembly/test-jar-with-dependencies.xml +++ b/integration-tests/cucumber-tests-platform-smartmetering/src/main/assembly/test-jar-with-dependencies.xml @@ -34,4 +34,4 @@ SPDX-License-Identifier: Apache-2.0 META-INF/cxf - \ No newline at end of file + diff --git a/integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/config/DlmsSimulatorConfig.java b/integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/config/DlmsSimulatorConfig.java index c4f9eed2af8..ced7bf1a278 100644 --- a/integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/config/DlmsSimulatorConfig.java +++ b/integration-tests/cucumber-tests-platform-smartmetering/src/test/java/org/opensmartgridplatform/cucumber/platform/smartmetering/config/DlmsSimulatorConfig.java @@ -14,14 +14,21 @@ @Configuration public class DlmsSimulatorConfig extends AbstractConfig { - public DlmsSimulatorConfig() {} + @Value("${web.service.truststore.location}") + private String truststoreLocation; - @Value("${dynamic.properties.base.url}") - private String dynamicPropertiesBaseUrl; + @Value("${web.service.truststore.password}") + private String truststorePassword; + + @Value("${web.service.truststore.type}") + private String truststoreType; + + @Value("${triggered.simulator.url}") + private String baseAddress; @Bean public SimulatorTriggerClient simulatorTriggerClient() throws SimulatorTriggerClientException { - - return new SimulatorTriggerClient(this.dynamicPropertiesBaseUrl); + return new SimulatorTriggerClient( + this.truststoreLocation, this.truststorePassword, this.truststoreType, this.baseAddress); } } diff --git a/integration-tests/cucumber-tests-platform-smartmetering/src/test/resources/cucumber-tests-platform-smartmetering.properties b/integration-tests/cucumber-tests-platform-smartmetering/src/test/resources/cucumber-tests-platform-smartmetering.properties index a0e34c44f57..1f8c79c34af 100644 --- a/integration-tests/cucumber-tests-platform-smartmetering/src/test/resources/cucumber-tests-platform-smartmetering.properties +++ b/integration-tests/cucumber-tests-platform-smartmetering/src/test/resources/cucumber-tests-platform-smartmetering.properties @@ -13,7 +13,7 @@ alarm.notifications.host=${server.domain} alarm.notifications.port=9598 # Settings for rest service to dynamically set DLMS attribute values in a device simulator. -dynamic.properties.base.url=https://${server.domain}/osgp-simulator-dlms-triggered/wakeup +dynamic.properties.base.url=${base.uri}osgp-simulator-dlms-triggered/wakeup # When waiting for a SmartMeter response notification for a correlation UID # retrieved earlier, what is the maximum duration in milliseconds after which @@ -60,4 +60,10 @@ jre.encryption.key.resource=classpath:osgp-secret-management-jre.key simulator.max.logicalids.per.port=100 smartmetering.firmware.path=/etc/osp/firmwarefiles -smartmetering.firmware.imageidentifier.extention=imgid \ No newline at end of file +smartmetering.firmware.imageidentifier.extention=imgid + + +web.service.truststore.location=${certificate.basepath}/trust.jks +web.service.truststore.password=123456 +web.service.truststore.type=jks +triggered.simulator.url=${base.uri}osgp-simulator-dlms-triggered/wakeup diff --git a/integration-tests/cucumber-tests-platform/src/test/resources/cucumber-tests-platform.properties b/integration-tests/cucumber-tests-platform/src/test/resources/cucumber-tests-platform.properties index f92888cfe94..e6e28269082 100644 --- a/integration-tests/cucumber-tests-platform/src/test/resources/cucumber-tests-platform.properties +++ b/integration-tests/cucumber-tests-platform/src/test/resources/cucumber-tests-platform.properties @@ -58,3 +58,4 @@ web.service.truststore.type=jks #firmware file location for loading firmware files into the DB firmware.file.path=/var/www/html/firmware +#triggered.simulator.url=https://localhost/osgp-simulator-dlms-triggered/wakeup diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml index 9dac6be6965..d0fed4e47ba 100644 --- a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml +++ b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/pom.xml @@ -29,8 +29,6 @@ SPDX-License-Identifier: Apache-2.0 ${project.version} true 1.8.0 - - 4.0.3 diff --git a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/src/main/java/org/opensmartgridplatform/adapter/protocol/dlms/simulator/trigger/SimulatorTriggerClient.java b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/src/main/java/org/opensmartgridplatform/adapter/protocol/dlms/simulator/trigger/SimulatorTriggerClient.java index 9f6e46697cd..5557ef716b1 100644 --- a/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/src/main/java/org/opensmartgridplatform/adapter/protocol/dlms/simulator/trigger/SimulatorTriggerClient.java +++ b/osgp/protocol-adapter-dlms/osgp-protocol-adapter-dlms/src/main/java/org/opensmartgridplatform/adapter/protocol/dlms/simulator/trigger/SimulatorTriggerClient.java @@ -8,16 +8,22 @@ import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response.Status; +import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.security.KeyStore; +import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; import java.util.List; +import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; +import lombok.extern.slf4j.Slf4j; import org.apache.cxf.configuration.jsse.TLSClientParameters; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; @@ -27,6 +33,7 @@ import org.opensmartgridplatform.shared.usermanagement.AbstractClient; import org.opensmartgridplatform.shared.usermanagement.ResponseException; +@Slf4j public class SimulatorTriggerClient extends AbstractClient { private static final String CONSTRUCTION_FAILED = "SimulatorTriggerClient construction failed"; @@ -50,10 +57,40 @@ public SimulatorTriggerClient( final String baseAddress) throws SimulatorTriggerClientException { + // test + log.info("baseAddress: {}", baseAddress); + final File truststoreLocationFile = new File(truststoreLocation); + log.info("{} is parent", truststoreLocationFile.getParentFile()); + if (truststoreLocationFile.exists()) { + log.info("{} exists", truststoreLocation); + if (truststoreLocationFile.getParentFile().isDirectory()) { + log.info("{} is directoru", truststoreLocationFile.getParentFile()); + Arrays.stream(truststoreLocationFile.getParentFile().listFiles()) + .forEach(file -> log.info("== {}", file.getName())); + } + } + // end test try (final InputStream stream = new FileInputStream(truststoreLocation)) { // Create the KeyStore. final KeyStore truststore = KeyStore.getInstance(truststoreType.toUpperCase()); + // test + final Iterator iterator = truststore.aliases().asIterator(); + log.info("== aliases == "); + while (iterator.hasNext()) { + final String alias = iterator.next(); + log.info("alias: {}", alias); + final Certificate certificate = truststore.getCertificate(alias); + log.info("certificate: {}", certificate.toString()); + final Certificate[] certificateChain = truststore.getCertificateChain(alias); + Arrays.stream(certificateChain) + .forEach(cc -> log.info("certificate chain: {}", cc.toString())); + log.info("creationdate: {}", truststore.getCreationDate(alias)); + } + log.info("== end of aliases == "); + + // end test + truststore.load(stream, truststorePassword.toCharArray()); // Create TrustManagerFactory and initialize it using the KeyStore. @@ -130,6 +167,14 @@ public void checkClientTrusted(final X509Certificate[] chain, final String authT tlsParams.setSecureSocketProtocol("TLSv1.2"); + try { + final SSLContext sc = SSLContext.getDefault(); + tlsParams.setUseHttpsURLConnectionDefaultSslSocketFactory(false); + tlsParams.setSSLSocketFactory(sc.getSocketFactory()); + } catch (final Exception e) { + throw new RuntimeException(e); + } + conduit.setTlsClientParameters(tlsParams); return client; diff --git a/runTestsAtRemoteServer.sh b/runTestsAtRemoteServer.sh index f002f431b8e..fa3efc5baa9 100755 --- a/runTestsAtRemoteServer.sh +++ b/runTestsAtRemoteServer.sh @@ -74,7 +74,7 @@ CMD="ssh -oStrictHostKeyChecking=no -oTCPKeepAlive=yes -oServerAliveInterval=50 ${CMD} echo '- Create zip file from files from server ...' -CMD="sudo tar zhcvf /tmp/${SERVER}-${PROJECT}.tgz /etc/osgp /etc/httpd/conf.d /usr/share/tomcat/conf /var/log/tomcat /var/log/osgp /var/lib/pgsql/9.6/data/pg_log --warning=no-file-changed || true" +CMD="sudo tar zhcvf /tmp/${SERVER}-${PROJECT}.tgz /etc/ssl/certs /etc/osgp /etc/httpd/conf.d /usr/share/tomcat/conf /var/log/tomcat /var/log/osgp /var/lib/pgsql/9.6/data/pg_log --warning=no-file-changed || true" echo " [${CMD}]" CMD="ssh -oStrictHostKeyChecking=no ${SSH_KEY_FILE} ${USER}@${SERVER} \"\"cd /data/software/${PROJECT} && ${CMD}\"\"" ${CMD}