forked from syslog4j/syslog4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use self-signed cert on classpath for SSL tests
- Loading branch information
Showing
3 changed files
with
59 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/org/productivity/java/syslog4j/test/net/SSLConfigUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.productivity.java.syslog4j.test.net; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
|
||
import org.productivity.java.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogConfigIF; | ||
import org.productivity.java.syslog4j.server.impl.net.tcp.ssl.SSLTCPNetSyslogServerConfigIF; | ||
|
||
public class SSLConfigUtil { | ||
|
||
public static final String KEYSTORE = "certs/ssltest.jks"; | ||
|
||
public static final String PASSWORD = "ssltest"; | ||
|
||
public static void configure(SSLTCPNetSyslogServerConfigIF config) | ||
throws Exception { | ||
final String keyStorePath = keyStorePath(); | ||
|
||
config.setKeyStore(keyStorePath); | ||
config.setKeyStorePassword(PASSWORD); | ||
|
||
config.setTrustStore(keyStorePath); | ||
config.setTrustStorePassword(PASSWORD); | ||
} | ||
|
||
public static void configure(SSLTCPNetSyslogConfigIF config) | ||
throws Exception { | ||
final String keyStorePath = keyStorePath(); | ||
|
||
config.setKeyStore(keyStorePath); | ||
config.setKeyStorePassword(PASSWORD); | ||
|
||
config.setTrustStore(keyStorePath); | ||
config.setTrustStorePassword(PASSWORD); | ||
} | ||
|
||
private static String keyStorePath() throws IOException, URISyntaxException { | ||
final URL url = SSLConfigUtil.class.getClassLoader().getResource(KEYSTORE); | ||
return new File(url.toURI()).getAbsolutePath(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters