Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions native/com_wolfssl_WolfSSLSession.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,11 +2761,11 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_sendHrrCookie
JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsMacDropCount
(JNIEnv* jenv, jobject jcl, jlong sslPtr)
{
word32 dropCount = 0;

(void)jenv;
(void)jcl;
(void)sslPtr;

word32 dropCount = 0;
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_DROP_STATS)
int ret = 0;
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
Expand All @@ -2782,11 +2782,11 @@ JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsMacDropCount
JNIEXPORT jlong JNICALL Java_com_wolfssl_WolfSSLSession_getDtlsReplayDropCount
(JNIEnv* jenv, jobject jcl, jlong sslPtr)
{
word32 dropCount = 0;

(void)jenv;
(void)jcl;
(void)sslPtr;

word32 dropCount = 0;
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_DTLS_DROP_STATS)
int ret = 0;
WOLFSSL* ssl = (WOLFSSL*)(uintptr_t)sslPtr;
Expand Down
3 changes: 2 additions & 1 deletion src/java/com/wolfssl/WolfSSLCertManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public synchronized int CertManagerLoadCAKeyStore(KeyStore ks)
cert = (X509Certificate) ks.getCertificate(name);
}

if (cert != null && cert.getBasicConstraints() >= 0) {
if (cert != null && (cert.getBasicConstraints() >= 0 ||
WolfSSL.trustPeerCertEnabled())) {
ret = CertManagerLoadCABuffer(cert.getEncoded(),
cert.getEncoded().length,
WolfSSL.SSL_FILETYPE_ASN1);
Expand Down
34 changes: 25 additions & 9 deletions src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@ protected WolfSSLImplementSSLSession getSession(
return null;
}

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

Expand Down Expand Up @@ -693,9 +694,15 @@ protected int addSession(WolfSSLImplementSSLSession session) {
}

/**
* Internal function to return a list of all session ID's
* Internal function to return a list of valid session IDs.
*
* Expired sessions should already have been invalidated before this call
* via updateTimeouts(), but callers may also invalidate sessions for
* other reasons. Filter validity here so callers can avoid an extra
* per-ID lookup.
*
* @param side server or client side to get list of ID's from
* @return enumerated session IDs
* @return enumerated valid session IDs
*/
protected Enumeration<byte[]> getAllIDs(int side) {
List<byte[]> ret = new ArrayList<>();
Expand All @@ -704,7 +711,7 @@ protected Enumeration<byte[]> getAllIDs(int side) {
for (Object obj : store.values()) {
WolfSSLImplementSSLSession current =
(WolfSSLImplementSSLSession)obj;
if (current.getSide() == side) {
if (current.getSide() == side && current.isValid()) {
ret.add(current.getId());
}
}
Expand Down Expand Up @@ -758,14 +765,24 @@ protected void updateTimeouts(int in, int side) {
diff = (now - current.creation.getTime()) / 1000;

if (diff < 0) {
/* session is from the future ... */ //@TODO
/* session is from the future ... */ /* TODO */

}

if (in > 0 && diff > in) {
if (in > 0 && diff >= in) {
current.invalidate();
}
try {
current.setNativeTimeout(in);
} catch (IllegalStateException e) {
/* Native WolfSSLSession has been freed,
* invalidate this session entry */
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Native session freed while updating " +
"timeout, invalidating cache entry: " +
e.getMessage());
current.invalidate();
}
current.setNativeTimeout(in);
}
}
}
Expand Down Expand Up @@ -803,4 +820,3 @@ protected synchronized void finalize() throws Throwable {
super.finalize();
}
}

4 changes: 2 additions & 2 deletions src/java/com/wolfssl/provider/jsse/WolfSSLContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ protected SSLEngine engineCreateSSLEngine()
try {
return new WolfSSLEngine(this.ctx, this.authStore, this.params);
} catch (WolfSSLException ex) {
throw new IllegalStateException("Unable to create engine");
throw new IllegalStateException("Unable to create engine", ex);
}
}

Expand Down Expand Up @@ -516,7 +516,7 @@ protected SSLEngine engineCreateSSLEngine(String host, int port)
return new WolfSSLEngine(this.ctx, this.authStore, this.params,
host, port);
} catch (WolfSSLException ex) {
throw new IllegalStateException("Unable to create engine");
throw new IllegalStateException("Unable to create engine", ex);
}
}

Expand Down
Loading
Loading