JSSE: fixes for some items found with SpotBugs

pull/221/head
Chris Conlon 2024-09-16 15:51:12 -06:00
parent a9c28d7377
commit b7ed1d3140
6 changed files with 25 additions and 10 deletions

View File

@ -501,7 +501,7 @@ public class WolfSSLX509Name {
}
/* TODO: wrap wolfSSL_X509_NAME_oneline() */
return null;
return "";
}
/**

View File

@ -389,7 +389,8 @@ public class WolfSSLContext extends SSLContextSpi {
SecureRandom sr) throws KeyManagementException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered engineInit(km=" + km + ", tm=" + tm + ", sr=" + sr +")");
"entered engineInit(km=" + Arrays.toString(km) +
", tm=" + Arrays.toString(tm) + ", sr=" + sr +")");
try {
authStore = new WolfSSLAuthStore(km, tm, sr, currentVersion);

View File

@ -1046,13 +1046,18 @@ public class WolfSSLEngineHelper {
* with HAVE_SECURE_RENEGOTIATION. Some JSSE consuming apps
* expect that secure renegotiation will be supported. */
int ret = this.ssl.useSecureRenegotiation();
if (ret != WolfSSL.SSL_SUCCESS && ret != WolfSSL.NOT_COMPILED_IN) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"error enabling secure renegotiation, ret = " + ret);
} else if (ret == 0) {
if (ret == WolfSSL.SSL_SUCCESS) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"enabled secure renegotiation support for session");
}
else if (ret == WolfSSL.NOT_COMPILED_IN) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"native secure renegotiation not compiled in");
}
else {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"error enabling secure renegotiation, ret = " + ret);
}
}
private void setLocalSigAlgorithms() {

View File

@ -264,7 +264,7 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession
/* use pseudo session ID if session tickets are being used */
if (this.ssl.getVersion().equals("TLSv1.3") ||
this.ssl.sessionTicketsEnabled()) {
return this.pseudoSessionID;
return this.pseudoSessionID.clone();
}
else {
return this.ssl.getSessionID();

View File

@ -46,7 +46,6 @@ public class WolfSSLServerSocket extends SSLServerSocket {
private boolean clientMode = false;
private boolean enableSessionCreation = true;
private WolfSSLDebug debug;
/**
* Create new WolfSSLServerSocket

View File

@ -511,8 +511,20 @@ public class WolfSSLTrustManager extends TrustManagerFactorySpi {
String caStoreDir = androidRoot.concat("etc/security/cacerts");
File cadir = new File(caStoreDir);
String[] cafiles = null;
if (cadir == null) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"Unable to open etc/security/cacerts, none loaded");
return null;
}
try {
cafiles = cadir.list();
if (cafiles != null) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"Found " + cafiles.length +
" CA files to load into KeyStore");
}
} catch (Exception e) {
/* Denied access reading cacerts directory */
WolfSSLDebug.log(getClass(), WolfSSLDebug.ERROR,
@ -520,8 +532,6 @@ public class WolfSSLTrustManager extends TrustManagerFactorySpi {
"CA certificates");
return null;
}
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"Found " + cafiles.length + " CA files to load into KeyStore");
/* Get factory for cert creation */
try {