Merge pull request #271 from rlm2002/updateSessionVals

Update additional stored session values
pull/256/merge
Chris Conlon 2025-06-03 12:13:52 -06:00 committed by GitHub
commit 9ee4cadde7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 62 additions and 6 deletions

View File

@ -64,6 +64,8 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
private final int port;
private final String host;
String protocol = null;
int packetBufSz = -1; /* max packet size for TLS record */
String cipherSuite = null; /* cipher suite used for this session */
Date creation = null;
Date accessed = null; /* when new connection was made using session */
byte[] pseudoSessionID = null; /* used with TLS 1.3*/
@ -508,6 +510,7 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
ByteArrayInputStream der;
X509Certificate exportCert;
if (ssl == null) {
throw new SSLPeerUnverifiedException(
"internal WolfSSLSession null, handshake not complete or " +
@ -724,13 +727,20 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
}
try {
return this.ssl.cipherGetName();
String currentCipher = this.ssl.cipherGetName();
if (currentCipher != null) {
if (!currentCipher.equals(this.cipherSuite)){
this.cipherSuite = currentCipher;
}
return currentCipher;
}
} catch (IllegalStateException | WolfSSLJNIException ex) {
Logger.getLogger(
WolfSSLImplementSSLSession.class.getName()).log(
Level.SEVERE, null, ex);
}
return null;
return this.cipherSuite;
}
/**
@ -801,6 +811,12 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
if ((nativeMax > 0) && (nativeMax > ret)) {
ret = nativeMax;
}
if (ret > this.packetBufSz) {
this.packetBufSz = ret;
}
} else if (this.packetBufSz >= 0) {
ret = this.packetBufSz;
}
final int tmpRet = ret;
@ -933,6 +949,46 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
ex.getMessage());
}
}
/* Update packet buffer size */
try {
int maxOutputSize = this.ssl.getMaxOutputSize();
if (this.packetBufSz < 0 || this.packetBufSz < maxOutputSize)
this.packetBufSz = maxOutputSize;
} catch (IllegalStateException ex) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Not able to update packet buffer size: " +
ex.getMessage());
}
/* Update cipher suite */
try {
if (this.ssl != null && this.cipherSuite == null) {
this.cipherSuite = this.ssl.cipherGetName();
if (this.cipherSuite != null && !this.cipherSuite.isEmpty()) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Updated cipher suite: " + this.cipherSuite);
}
}
} catch (WolfSSLJNIException ex) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Not able to update cipher suite: " +
ex.getMessage());
}
/* Update peer certificates */
try {
if (this.peerCerts == null) {
this.getPeerCertificates();
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
() -> "Updated peer certificates for session" +
"getPeerCertificates() caches peer certs");
}
} catch (SSLPeerUnverifiedException ex) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO, () ->
"Not able to update peer certificates: " + ex.getMessage());
}
}
/**