@@ -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
0 commit comments