Skip to content

Commit dd6aab3

Browse files
committed
wolfJSSE fixes for FIPS test coverage
1 parent 13cb353 commit dd6aab3

17 files changed

Lines changed: 1774 additions & 218 deletions

src/java/com/wolfssl/WolfSSLCertManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ public synchronized int CertManagerLoadCAKeyStore(KeyStore ks)
179179
cert = (X509Certificate) ks.getCertificate(name);
180180
}
181181

182-
if (cert != null && cert.getBasicConstraints() >= 0) {
182+
if (cert != null && (cert.getBasicConstraints() >= 0 ||
183+
WolfSSL.trustPeerCertEnabled())) {
183184
ret = CertManagerLoadCABuffer(cert.getEncoded(),
184185
cert.getEncoded().length,
185186
WolfSSL.SSL_FILETYPE_ASN1);

src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ protected WolfSSLImplementSSLSession getSession(
331331
return null;
332332
}
333333

334-
/* Return new session if in server mode, or if host is null */
335-
if (!clientMode || host == null) {
334+
/* Unknown port (-1) is a valid SSLEngine host hint.
335+
* Skip cache keying. */
336+
if (!clientMode || host == null || port < 0) {
336337
return this.getSession(ssl, clientMode, host, port);
337338
}
338339

@@ -758,14 +759,20 @@ protected void updateTimeouts(int in, int side) {
758759
diff = (now - current.creation.getTime()) / 1000;
759760

760761
if (diff < 0) {
761-
/* session is from the future ... */ //@TODO
762+
/* session is from the future ... */ /* TODO */
762763

763764
}
764765

765-
if (in > 0 && diff > in) {
766+
if (in > 0 && diff >= in) {
767+
current.invalidate();
768+
}
769+
try {
770+
current.setNativeTimeout(in);
771+
} catch (IllegalStateException e) {
772+
/* Native WolfSSLSession has been freed,
773+
* invalidate this session entry */
766774
current.invalidate();
767775
}
768-
current.setNativeTimeout(in);
769776
}
770777
}
771778
}
@@ -803,4 +810,3 @@ protected synchronized void finalize() throws Throwable {
803810
super.finalize();
804811
}
805812
}
806-

src/java/com/wolfssl/provider/jsse/WolfSSLContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ protected SSLEngine engineCreateSSLEngine()
488488
try {
489489
return new WolfSSLEngine(this.ctx, this.authStore, this.params);
490490
} catch (WolfSSLException ex) {
491-
throw new IllegalStateException("Unable to create engine");
491+
throw new IllegalStateException("Unable to create engine", ex);
492492
}
493493
}
494494

@@ -516,7 +516,7 @@ protected SSLEngine engineCreateSSLEngine(String host, int port)
516516
return new WolfSSLEngine(this.ctx, this.authStore, this.params,
517517
host, port);
518518
} catch (WolfSSLException ex) {
519-
throw new IllegalStateException("Unable to create engine");
519+
throw new IllegalStateException("Unable to create engine", ex);
520520
}
521521
}
522522

0 commit comments

Comments
 (0)