Skip to content

Commit 1a1a4ab

Browse files
authored
Merge pull request #279 from rlm2002/updateSessionVals
catch IllegalStateException on getMaxOutputSize()
2 parents 60a4842 + f8472b7 commit 1a1a4ab

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

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

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ public synchronized Certificate[] getPeerCertificates()
520520
try {
521521
x509 = this.ssl.getPeerCertificate();
522522
} catch (IllegalStateException | WolfSSLJNIException ex) {
523-
Logger.getLogger(
524-
WolfSSLImplementSSLSession.class.getName()).log(
525-
Level.SEVERE, null, ex);
523+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
524+
() -> "Error getting peer certificate: "
525+
+ ex.getMessage());
526526
x509 = 0;
527527
}
528528

@@ -636,9 +636,9 @@ public synchronized javax.security.cert.X509Certificate[] getPeerCertificateChai
636636

637637
} catch (IllegalStateException | WolfSSLJNIException |
638638
WolfSSLException ex) {
639-
Logger.getLogger(
640-
WolfSSLImplementSSLSession.class.getName()).log(
641-
Level.SEVERE, null, ex);
639+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
640+
() -> "Error getting peer certificate chain: "
641+
+ ex.getMessage());
642642
}
643643
return null;
644644
}
@@ -682,9 +682,8 @@ public synchronized Principal getPeerPrincipal()
682682

683683
} catch (IllegalStateException | WolfSSLJNIException |
684684
WolfSSLException ex) {
685-
Logger.getLogger(
686-
WolfSSLImplementSSLSession.class.getName()).log(
687-
Level.SEVERE, null, ex);
685+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
686+
() -> "Error getting peer principal: " + ex.getMessage());
688687
}
689688
return null;
690689
}
@@ -735,9 +734,8 @@ public synchronized String getCipherSuite() {
735734
return currentCipher;
736735
}
737736
} catch (IllegalStateException | WolfSSLJNIException ex) {
738-
Logger.getLogger(
739-
WolfSSLImplementSSLSession.class.getName()).log(
740-
Level.SEVERE, null, ex);
737+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
738+
() -> "Error getting cipher suite: " + ex.getMessage());
741739
}
742740

743741
return this.cipherSuite;
@@ -804,17 +802,29 @@ public synchronized int getPacketBufferSize() {
804802

805803
/* Try to get maximum TLS record size from native wolfSSL */
806804
if (ssl != null) {
807-
nativeMax = ssl.getMaxOutputSize();
808-
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
809-
() -> "ssl.getMaxOutputSize() returned: " + nativeMax);
810-
811-
if ((nativeMax > 0) && (nativeMax > ret)) {
812-
ret = nativeMax;
805+
try {
806+
nativeMax = ssl.getMaxOutputSize();
807+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
808+
() -> "ssl.getMaxOutputSize() returned: " + nativeMax);
809+
if ((nativeMax > 0) && (nativeMax > ret)) {
810+
ret = nativeMax;
811+
}
812+
if (ret > this.packetBufSz) {
813+
this.packetBufSz = ret;
814+
}
815+
} catch (IllegalStateException ex) {
816+
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
817+
() -> "Error getting packet buffer size: "
818+
+ ex.getMessage());
819+
/* If ssl.getMaxOutputSize failed, check for cached value */
820+
if (this.packetBufSz > ret) {
821+
ret = this.packetBufSz;
822+
} else {
823+
/* Cache ret if greater than or equal to packetBufSz */
824+
this.packetBufSz = ret;
825+
}
813826
}
814827

815-
if (ret > this.packetBufSz) {
816-
this.packetBufSz = ret;
817-
}
818828
} else if (this.packetBufSz >= 0) {
819829
ret = this.packetBufSz;
820830
}

0 commit comments

Comments
 (0)