Skip to content

Commit

Permalink
Throwing exception if TLS.keystore_path doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Jan 25, 2024
1 parent e0cf7b2 commit 172adba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/org/jgroups/stack/GossipRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public GossipRouter init() throws Exception {
.registerProbeHandler(this)
.printHeaders(b -> String.format("GossipRouter [addr=%s, cluster=GossipRouter, version=%s]\n",
localAddress(), Version.description));
tls.init();
return this;
}

Expand Down Expand Up @@ -919,6 +918,7 @@ public static void main(String[] args) throws Exception {
.setPasscode(diag_passcode);
String type="";
if(tls.enabled()) {
tls.init();
SSLContext context=tls.createContext();
SocketFactory socket_factory=tls.createSocketFactory(context);
router.socketFactory(socket_factory);
Expand Down
7 changes: 7 additions & 0 deletions src/org/jgroups/util/TLS.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLServerSocket;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -111,6 +113,11 @@ public void init() throws Exception {
truststore_type=keystore_type;
truststore_password=keystore_password;
}
if(keystore_path != null) {
File tmp=new File(keystore_path);
if(!tmp.exists())
throw new FileNotFoundException(keystore_path);
}
}

public SSLContext createContext() {
Expand Down

0 comments on commit 172adba

Please sign in to comment.