Skip to content

Commit d86c786

Browse files
committed
Added server side SSL debug for client-cert test
1 parent a8d68c3 commit d86c786

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

servlet/security-clientcert/src/test/java/org/javaee7/servlet/security/clientcert/SecureServletTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static java.time.temporal.ChronoUnit.DAYS;
77
import static java.util.logging.Level.FINEST;
88
import static org.javaee7.ServerOperations.addCertificateToContainerTrustStore;
9+
import static org.javaee7.ServerOperations.addContainerSystemProperty;
910
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
1011
import static org.junit.Assert.assertTrue;
1112

@@ -88,7 +89,7 @@ public static WebArchive createDeployment() throws FileNotFoundException, IOExce
8889
Provider provider = new BouncyCastleProvider();
8990
Security.addProvider(provider);
9091

91-
// Enable to get detailed logging about the SSL handshake
92+
// Enable to get detailed logging about the SSL handshake on the client
9293

9394
// For an explanation of the TLS handshake see: https://tls.ulfheim.net
9495

@@ -109,6 +110,13 @@ public static WebArchive createDeployment() throws FileNotFoundException, IOExce
109110

110111
// Create a new local key store containing the client private key and the certificate
111112
createKeyStore(clientKeyPair.getPrivate(), clientCertificate);
113+
114+
// Enable to get detailed logging about the SSL handshake on the server
115+
116+
if (System.getProperty("ssl.debug") != null) {
117+
System.out.println("Setting server SSL debug on");
118+
addContainerSystemProperty("javax.net.debug", "ssl:handshake");
119+
}
112120

113121
// Add the client certificate that we just generated to the trust store of the server.
114122
// That way the server will trust our certificate.

test-utils/src/main/java/org/javaee7/ServerOperations.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,29 @@ public static URL toContainerHttps(URL url) {
167167
return null;
168168
}
169169

170+
public static void addContainerSystemProperty(String key, String value) {
171+
String javaEEServer = System.getProperty("javaEEServer");
172+
173+
if ("glassfish-remote".equals(javaEEServer) || "payara-remote".equals(javaEEServer)) {
174+
175+
System.out.println("Adding system property");
176+
177+
List<String> cmd = new ArrayList<>();
178+
179+
cmd.add("create-jvm-options");
180+
cmd.add("-D" + key + "=" + value);
181+
182+
CliCommands.payaraGlassFish(cmd);
183+
184+
} else {
185+
if (javaEEServer == null) {
186+
System.out.println("javaEEServer not specified");
187+
} else {
188+
System.out.println(javaEEServer + " not supported");
189+
}
190+
}
191+
}
192+
170193
public static void restartContainer() {
171194
// Arquillian connectors can stop/start already, but not on demand by code
172195

0 commit comments

Comments
 (0)