ppalaga commented on code in PR #3731:
URL: https://github.com/apache/camel-quarkus/pull/3731#discussion_r850788495


##########
integration-tests/paho-mqtt5/src/main/java/org/apache/camel/quarkus/component/paho/mqtt5/it/PahoMqtt5Resource.java:
##########
@@ -159,18 +167,22 @@ private String brokerUrl(String protocol) {
         return ConfigProvider.getConfig().getValue("paho5.broker." + protocol 
+ ".url", String.class);
     }
 
-    private void setKeyStore(String keystore, String password) {
-        InputStream in = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);
+    private String setKeyStore(String keystore, String password) {
+        String tmpKeystore = null;
+
+        try (InputStream in = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);) {
+            tmpKeystore = File.createTempFile("keystore-", ".jks").getPath();
+            Files.copy(in, Paths.get(tmpKeystore), 
StandardCopyOption.REPLACE_EXISTING);
+
+            System.setProperty("javax.net.ssl.keyStore", tmpKeystore);
+            System.setProperty("javax.net.ssl.keyStorePassword", password);
+            System.setProperty("javax.net.ssl.trustStore", tmpKeystore);
+            System.setProperty("javax.net.ssl.trustStorePassword", password);
 
-        try {
-            Files.copy(in, Paths.get(keystore));
         } catch (Exception e) {

Review Comment:
   Sorry, should be `throw new RuntimeException("Could not copy "+ keystore +" 
from the classpath to " + tmpKeystore, e);` - we do not want to swallow the 
exception.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to