Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSSE: fixes for some items found with SpotBugs #221

Merged
merged 1 commit into from
Sep 17, 2024
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
2 changes: 1 addition & 1 deletion src/java/com/wolfssl/WolfSSLX509Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public String toString() {
}

/* TODO: wrap wolfSSL_X509_NAME_oneline() */
return null;
return "";
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/java/com/wolfssl/provider/jsse/WolfSSLContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ protected void engineInit(KeyManager[] km, TrustManager[] tm,
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);
Expand Down
13 changes: 9 additions & 4 deletions src/java/com/wolfssl/provider/jsse/WolfSSLEngineHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,18 @@ private void setLocalSecureRenegotiation() {
* 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public synchronized byte[] getId() {
/* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class WolfSSLServerSocket extends SSLServerSocket {

private boolean clientMode = false;
private boolean enableSessionCreation = true;
private WolfSSLDebug debug;

/**
* Create new WolfSSLServerSocket
Expand Down
14 changes: 12 additions & 2 deletions src/java/com/wolfssl/provider/jsse/WolfSSLTrustManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,27 @@ private KeyStore LoadAndroidSystemCertsManually(String requiredType) {
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,
"Permission error when trying to read system " +
"CA certificates");
return null;
}
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"Found " + cafiles.length + " CA files to load into KeyStore");

/* Get factory for cert creation */
try {
Expand Down