Skip to content
Snippets Groups Projects
Commit 0fbeb3d5 authored by Félix  Sidokhine's avatar Félix Sidokhine
Browse files

fixed SSL reload issue after install

Change-Id: I69a4ba199af4a68ef92a441df3bb413aa1146542
parent 1b3e4709
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.DirResourceSet;
import org.apache.catalina.webresources.JarResourceSet;
import org.apache.catalina.webresources.StandardRoot;
import org.apache.coyote.http11.Http11NioProtocol;
import org.apache.tomcat.util.descriptor.web.ErrorPage;
import java.io.File;
......@@ -54,6 +55,19 @@ public class TomcatLauncher {
this.startServer();
}
//Swap connectors fix.
public void swapConnectors(){
if(getTomcat().getConnector().findSslHostConfigs() == null || getTomcat().getConnector().findSslHostConfigs().length < 1){
getTomcat().getConnector().findSslHostConfigs()[0].setTruststoreFile(System.getProperty("user.dir") + File.separator + "keystore.jks");
getTomcat().getConnector().findSslHostConfigs()[0].setTruststorePassword("changeit");
getTomcat().getConnector().findSslHostConfigs()[0].setCertificateVerification("optional");
((Http11NioProtocol) getTomcat().getConnector().getProtocolHandler()).reloadSslHostConfigs();
}
else{
log.error("Could not reload SSL configuration because the server is not running over SSL!");
}
}
public TomcatLauncher(int port, String certificateFile, String keyFile) {
if (!Files.exists(Paths.get(System.getProperty("user.dir") + File.separator + certificateFile)) ||
!Files.exists(Paths.get(System.getProperty("user.dir") + File.separator + keyFile))) {
......
......@@ -43,6 +43,7 @@ import java.security.KeyStore;
import static net.jami.jams.server.Server.certificateAuthority;
import static net.jami.jams.server.Server.dataStore;
import static net.jami.jams.server.Server.nameServer;
import static net.jami.jams.server.Server.tomcatLauncher;
import static net.jami.jams.server.Server.userAuthenticationModule;
@Slf4j
......@@ -118,6 +119,8 @@ public class InstallationFinalizer {
fos.close();
log.info("Successfully built keystore for for tomcat!");
Server.isInstalled.set(true);
//fix to swap connectors - this assumes you are running with an SSL certificate
tomcatLauncher.swapConnectors();
log.info("The installation has completed successfully, you can now use JAMS!");
} catch (Exception e) {
log.error("Could not save settings to disk with error: " + e.toString());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment