Skip to content

Commit 17484fe

Browse files
author
arjan
committed
Updates and comments for running on JDK 11
1 parent ad7dd94 commit 17484fe

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@
136136
<dependency>
137137
<groupId>org.bouncycastle</groupId>
138138
<artifactId>bcprov-jdk15on</artifactId>
139-
<version>1.59</version>
139+
<version>1.61</version>
140140
</dependency>
141141
<dependency>
142142
<groupId>org.bouncycastle</groupId>
143143
<artifactId>bcpkix-jdk15on</artifactId>
144-
<version>1.59</version>
144+
<version>1.61</version>
145145
</dependency>
146146
</dependencies>
147147
</dependencyManagement>
@@ -229,7 +229,7 @@
229229
<dependency>
230230
<groupId>net.sourceforge.htmlunit</groupId>
231231
<artifactId>htmlunit</artifactId>
232-
<version>2.34.0</version>
232+
<version>2.35.0</version>
233233
<scope>test</scope>
234234
</dependency>
235235
<dependency>

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public class SecureServletTest {
6666
private static Logger log = Logger.getLogger(SecureServletTest.class.getName());
6767

6868
private static final String WEBAPP_SRC = "src/main/webapp";
69+
70+
// static {
71+
// Security.insertProviderAt(new BouncyCastleProvider(), 1);
72+
// }
6973

7074
@ArquillianResource
7175
private URL base;
@@ -76,6 +80,31 @@ public class SecureServletTest {
7680

7781
@Deployment(testable = false)
7882
public static WebArchive createDeployment() throws FileNotFoundException, IOException {
83+
84+
// Note for JDK 11+, the server needs to be run with a sufficiently new version of JDK 11 or 12.
85+
// Older versions throw this exception:
86+
87+
// java.lang.UnsupportedOperationException: Not supported yet.
88+
// at java.base/sun.security.ssl.HandshakeHash$CloneableHash.archived(HandshakeHash.java:616)
89+
// at java.base/sun.security.ssl.HandshakeHash$T12HandshakeHash.archived(HandshakeHash.java:546)
90+
// at java.base/sun.security.ssl.HandshakeHash.archived(HandshakeHash.java:188)
91+
// at java.base/sun.security.ssl.CertificateVerify$T12CertificateVerifyMessage.<init>(CertificateVerify.java:650)
92+
// at java.base/sun.security.ssl.CertificateVerify$T12CertificateVerifyConsumer.consume(CertificateVerify.java:771)
93+
// at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
94+
// at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:448)
95+
// at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1065)
96+
// at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1052)
97+
// at java.base/java.security.AccessController.doPrivileged(Native Method)
98+
// at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:999)
99+
100+
// See https://bugs.openjdk.java.net/browse/JDK-8214098
101+
102+
// Works:
103+
// OpenJDK Runtime Environment Zulu11.31+11-CA (build 11.0.3+7-LTS)
104+
105+
// Doesn't work:
106+
// openjdk version "11.0.3" 2019-04-16
107+
// OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu1)
79108

80109
System.out.println("\n*********** DEPLOYMENT START ***************************");
81110

@@ -134,6 +163,12 @@ public void setup() throws FileNotFoundException, IOException {
134163

135164
System.out.println("\n*********** SETUP START ***************************");
136165

166+
String algorithms = Security.getProperty("jdk.tls.disabledAlgorithms");
167+
168+
// PSS can't be used with JDK11 and 12, will likely be fixed in JDK13
169+
// See https://bugs.openjdk.java.net/browse/JDK-8216039
170+
Security.setProperty("jdk.tls.disabledAlgorithms", algorithms + " ,RSASSA-PSS");
171+
137172
webClient = new WebClient();
138173

139174
// First get the HTTPS URL for which the server is listening
@@ -177,6 +212,8 @@ public void setup() throws FileNotFoundException, IOException {
177212
// Client -> Server : the key store's private keys and certificates are used to sign
178213
// and sent a reply to the server
179214
webClient.getOptions().setSSLClientCertificate(new File(clientKeyStorePath).toURI().toURL(), "changeit", "jks");
215+
webClient.getOptions().setTimeout(0);
216+
180217

181218
// First do a request to install Bouncy Castle as provider
182219
// This is a normal HTTP request and doesn't use certificate authentication
@@ -193,6 +230,31 @@ public void tearDown() throws IOException {
193230
log.log(INFO, "Bouncy Castle provider removed: {0}", pageb.getContent());
194231

195232
webClient.getCookieManager().clearCookies();
233+
234+
// Internally throws:
235+
//
236+
// TransportContext.java:313|Fatal (INTERNAL_ERROR): closing inbound before receiving peer's close_notify (
237+
// "throwable" : {
238+
// javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
239+
// at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
240+
// at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
241+
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
242+
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
243+
// at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
244+
// at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
245+
// at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
246+
// at org.apache.http.impl.BHttpConnectionBase.close(BHttpConnectionBase.java:325)
247+
// at org.apache.http.impl.conn.LoggingManagedHttpClientConnection.close(LoggingManagedHttpClientConnection.java:81)
248+
// at org.apache.http.impl.conn.CPoolEntry.closeConnection(CPoolEntry.java:70)
249+
// at org.apache.http.impl.conn.CPoolEntry.close(CPoolEntry.java:96)
250+
// at org.apache.http.pool.AbstractConnPool.shutdown(AbstractConnPool.java:148)
251+
// at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:411)
252+
// at com.gargoylesoftware.htmlunit.HttpWebConnection.close(HttpWebConnection.java:1011)
253+
//
254+
// Visible when -Dssl.debug is used
255+
//
256+
// Should be fixed in JDK11.03, but isn't?
257+
// See https://stackoverflow.com/questions/52016415/jdk-11-ssl-error-on-valid-certificate-working-in-previous-versions
196258
webClient.close();
197259
System.out.println("\n*********** TEST END ***************************\n");
198260
}
@@ -201,6 +263,8 @@ public void tearDown() throws IOException {
201263
public void testGetWithCorrectCredentials() throws Exception {
202264

203265
System.out.println("\n*********** TEST START ***************************\n");
266+
267+
Security.insertProviderAt(new BouncyCastleProvider(), 1);
204268

205269
try {
206270

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static void addCertificateToContainerTrustStore(Certificate clientCertifi
110110

111111
KeyStore keyStore = null;
112112
try (InputStream in = new FileInputStream(cacertsPath.toAbsolutePath().toFile())) {
113-
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
113+
keyStore = KeyStore.getInstance("JKS");
114114
keyStore.load(in, "changeit".toCharArray());
115115

116116
keyStore.setCertificateEntry("arquillianClientTestCert", clientCertificate);
@@ -172,7 +172,7 @@ public static URL toContainerHttps(URL url) {
172172
}
173173

174174
private static String getPayaraDomainFromServer() {
175-
System.out.println("Getting Payara domaain from server");
175+
System.out.println("Getting Payara domain from server");
176176

177177
List<String> output = new ArrayList<>();
178178
List<String> cmd = new ArrayList<>();
@@ -187,12 +187,16 @@ private static String getPayaraDomainFromServer() {
187187
continue;
188188
}
189189

190-
if (line.endsWith(" running")) {
190+
if (line.contains(" running")) {
191191
domain = line.substring(0, line.lastIndexOf(" running"));
192192
break;
193193
}
194194
}
195195

196+
if (domain == null) {
197+
throw new IllegalStateException("Running domain could not be obtained for target Payara. Please specify explicitly using -Dpayara_domain");
198+
}
199+
196200
return domain;
197201
}
198202

0 commit comments

Comments
 (0)