Merge pull request #266 from cconlon/cursorFixes

Clean up Cursor/VSCode IDE warnings
pull/259/head
JacobBarthelmeh 2025-05-12 16:16:20 -06:00 committed by GitHub
commit 35083fad34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 40 additions and 156 deletions

View File

@ -21,8 +21,6 @@
package com.wolfssl;
import com.wolfssl.WolfSSLException;
/**
* Wraps a native ecc_key structure pointer.
*

View File

@ -27,8 +27,6 @@ import java.security.KeyStoreException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateEncodingException;
import com.wolfssl.WolfSSLDebug;
import com.wolfssl.WolfSSLException;
/**
* CertManager class which wraps the native WolfSSL embedded SSL library.

View File

@ -29,7 +29,6 @@ import java.security.interfaces.RSAPublicKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.ECPrivateKey;
import com.wolfssl.WolfSSLDebug;
/**
* WolfSSLCertRequest class, wraps native X509_REQ functionality.
@ -259,7 +258,6 @@ public class WolfSSLCertRequest {
public void setPublicKey(String filePath, int keyType, int format)
throws IllegalStateException, IOException, WolfSSLException {
int ret = 0;
File keyFile = null;
byte[] fileBytes = null;
@ -560,7 +558,6 @@ public class WolfSSLCertRequest {
String digestAlg) throws IllegalStateException, IOException,
WolfSSLException {
int ret = 0;
File keyFile = null;
byte[] fileBytes = null;

View File

@ -26,7 +26,6 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -46,7 +45,6 @@ import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateEncodingException;
import com.wolfssl.WolfSSLDebug;
/**
* WolfSSLCertificate class, wraps native wolfSSL WOLFSSL_X509 functionality.
@ -461,7 +459,6 @@ public class WolfSSLCertificate implements Serializable {
throws IllegalStateException, WolfSSLException {
int ret;
long x509CertPtr = 0;
long x509NamePtr = 0;
confirmObjectIsActive();
@ -549,7 +546,6 @@ public class WolfSSLCertificate implements Serializable {
public void setPublicKey(String filePath, int keyType, int format)
throws IllegalStateException, IOException, WolfSSLException {
int ret = 0;
File keyFile = null;
byte[] fileBytes = null;
@ -991,7 +987,6 @@ public class WolfSSLCertificate implements Serializable {
String digestAlg) throws IllegalStateException, IOException,
WolfSSLException {
int ret = 0;
File keyFile = null;
byte[] fileBytes = null;

View File

@ -23,10 +23,6 @@ package com.wolfssl;
import java.util.Arrays;
import java.nio.ByteBuffer;
import com.wolfssl.WolfCryptEccKey;
import com.wolfssl.WolfSSLDebug;
import com.wolfssl.WolfSSLException;
import com.wolfssl.WolfSSLJNIException;
/**
* Wraps a native WolfSSL context object and contains methods directly related

View File

@ -22,7 +22,6 @@
package com.wolfssl;
import java.nio.ByteBuffer;
import com.wolfssl.WolfCryptEccKey;
/**
* wolfSSL ECC Shared Secret Callback Interface.

View File

@ -20,11 +20,8 @@
*/
package com.wolfssl;
import java.util.Date;
import java.sql.Timestamp;
import com.wolfssl.WolfSSLLoggingCallback;
/**
* Utility class to help with JSSE-level functionality.
*

View File

@ -31,9 +31,6 @@ import java.lang.StringBuilder;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import com.wolfssl.WolfSSLException;
import com.wolfssl.WolfSSLJNIException;
/**
* Wraps a native WolfSSL session object and contains methods directly related
* to the SSL/TLS session.

View File

@ -21,8 +21,6 @@
package com.wolfssl;
import java.nio.ByteBuffer;
/**
* wolfSSL TLS 1.3 Secret Callback Interface.
* This interface specifies how applications should implement the TLS 1.3

View File

@ -20,8 +20,6 @@
*/
package com.wolfssl;
import com.wolfssl.WolfSSLDebug;
/**
* WolfSSLX509Name class, wraps native WOLFSSL_X509_NAME functionality.
*/

View File

@ -21,14 +21,11 @@
package com.wolfssl.provider.jsse;
import java.io.ByteArrayOutputStream;
import java.security.KeyManagementException;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import javax.security.auth.x500.X500Principal;
import java.util.ArrayList;
import java.util.Arrays;
import javax.net.ssl.KeyManager;
@ -39,7 +36,6 @@ import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509KeyManager;
import javax.net.ssl.X509TrustManager;
import com.wolfssl.WolfSSL;

View File

@ -604,7 +604,6 @@ public class WolfSSLEngine extends SSLEngine {
int totalIn = 0;
int sendSz = 0;
int inputLeft = 0;
ByteBuffer dataBuf;
byte[] dataArr;
int[] pos = new int[len]; /* in[] positions */
int[] limit = new int[len]; /* in[] limits */

View File

@ -33,16 +33,13 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Collections;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.ExtendedSSLSession;
import javax.net.ssl.SNIHostName;
import javax.net.ssl.SNIServerName;
@ -57,8 +54,7 @@ import javax.net.ssl.X509KeyManager;
* @author wolfSSL
*/
@SuppressWarnings("deprecation")
public class WolfSSLImplementSSLSession extends ExtendedSSLSession
implements SSLSession {
public class WolfSSLImplementSSLSession extends ExtendedSSLSession {
private WolfSSLSession ssl = null;
private final WolfSSLAuthStore authStore;

View File

@ -22,16 +22,11 @@
package com.wolfssl.provider.jsse;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactorySpi;
import javax.net.ssl.ManagerFactoryParameters;
@ -73,7 +68,6 @@ public class WolfSSLKeyManager extends KeyManagerFactorySpi {
throws KeyStoreException {
KeyStore sysStore = null;
InputStream stream = null;
String pass = System.getProperty("javax.net.ssl.keyStorePassword");
String file = System.getProperty("javax.net.ssl.keyStore");
String type = System.getProperty("javax.net.ssl.keyStoreType");

View File

@ -31,7 +31,6 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.X509KeyManager;
import javax.net.ssl.X509ExtendedKeyManager;
import com.wolfssl.WolfSSLDebug;
@ -42,8 +41,7 @@ import com.wolfssl.WolfSSLDebug;
*
* @author wolfSSL
*/
public class WolfSSLKeyX509 extends X509ExtendedKeyManager
implements X509KeyManager {
public class WolfSSLKeyX509 extends X509ExtendedKeyManager {
private KeyStore store;
private char[] password;

View File

@ -169,7 +169,6 @@ public final class WolfSSLProvider extends Provider {
* function
*/
public void setDevId(int devId) throws WolfSSLException {
int ret = 0;
/* Store devId into static WolfSSL variable, used by
* WolfSSLContext (SSLContext) */

View File

@ -31,8 +31,6 @@ import javax.net.ssl.SSLParameters;
import com.wolfssl.WolfSSL;
import com.wolfssl.WolfSSLDebug;
import com.wolfssl.WolfSSLSession;
import com.wolfssl.WolfSSLContext;
/**
* wolfSSL implementation of SSLServerSocket

View File

@ -39,7 +39,6 @@ import javax.net.ssl.SSLParameters;
import javax.net.ssl.SNIServerName;
import javax.net.ssl.SNIHostName;
import javax.net.ssl.StandardConstants;
import javax.net.ssl.X509TrustManager;
import javax.net.ssl.X509ExtendedTrustManager;
import javax.security.auth.x500.X500Principal;
@ -56,8 +55,7 @@ import java.security.cert.Certificate;
*
* @author wolfSSL
*/
public final class WolfSSLTrustX509 extends X509ExtendedTrustManager
implements X509TrustManager {
public final class WolfSSLTrustX509 extends X509ExtendedTrustManager {
private KeyStore store = null;
@ -645,7 +643,6 @@ public final class WolfSSLTrustX509 extends X509ExtendedTrustManager
String endpointIdAlgo = null;
SSLParameters sslParams = null;
SSLSession session = null;
/* Hostname verification on Socket done only if Socket is of SSLSocket,
* not null, and connected */

View File

@ -23,8 +23,6 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.List;
@ -32,7 +30,6 @@ import java.util.Arrays;
import java.util.ArrayList;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLContext;
import java.io.FileInputStream;
import javax.net.SocketFactory;
@ -161,6 +158,7 @@ public class WolfSSLContextTest {
KeyManagerFactory km;
TrustManagerFactory tm;
KeyStore pKey, cert;
SSLSocketFactory ssf;
System.out.print("\tgetSocketFactory()");
@ -198,8 +196,8 @@ public class WolfSSLContextTest {
ctx.init(km.getKeyManagers(), tm.getTrustManagers(), null);
SSLSocketFactory sf = ctx.getSocketFactory();
ssf = ctx.getSocketFactory();
assertNotNull(ssf);
}
System.out.println("\t\t... passed");
@ -269,6 +267,7 @@ public class WolfSSLContextTest {
/* test for getting session context @TODO additional tests */
try {
SSLSessionContext sess = ctx.getServerSessionContext();
assertNotNull(sess);
} catch (UnsupportedOperationException e) {
System.out.println("\t\t... failed");
fail("Failed to get SSLSessionContext");
@ -277,6 +276,7 @@ public class WolfSSLContextTest {
/* test for getting client session context @TODO additional tests */
try {
SSLSessionContext sess = ctx.getClientSessionContext();
assertNotNull(sess);
} catch (UnsupportedOperationException e) {
System.out.println("\t\t... failed");
fail("Failed to return client SSLSessionContext");

View File

@ -62,9 +62,7 @@ import org.junit.Rule;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.rules.Timeout;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import com.wolfssl.provider.jsse.WolfSSLEngine;

View File

@ -50,7 +50,6 @@ public class WolfSSLKeyX509Test {
private static WolfSSLTestFactory tf;
private String provider = "wolfJSSE";
private javax.security.cert.X509Certificate[] certs;
@BeforeClass
public static void testProviderInstallationAtRuntime()
@ -82,7 +81,6 @@ public class WolfSSLKeyX509Test {
X509KeyManager km;
X509Certificate[] chain;
String[] alias;
String str;
System.out.print("\tTesting getClientAliases");

View File

@ -23,8 +23,6 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.ArrayList;
@ -36,7 +34,6 @@ import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;
@ -192,15 +189,13 @@ public class WolfSSLServerSocketFactoryTest {
System.out.print("\tcreateSocket()");
for (int i = 0; i < sockFactories.size(); i++) {
String addrStr = "www.example.com";
InetAddress addr;
int port = 11118;
int backlog = 0;
SSLServerSocketFactory sf = sockFactories.get(i);
SSLServerSocket s = null;
try {
addr = InetAddress.getByName("www.example.com");
InetAddress.getByName("www.example.com");
} catch (UnknownHostException e) {
/* skip test if no Internet connection available */
System.out.println("\t\t\t... skipped");

View File

@ -23,8 +23,6 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.ArrayList;
@ -275,7 +273,6 @@ public class WolfSSLServerSocketTest {
throws NoSuchProviderException, NoSuchAlgorithmException,
IOException {
int port = 11118;
System.out.print("\tgetEnabledCipherSuites()");
for (int i = 0; i < sockFactories.size(); i++) {

View File

@ -23,8 +23,6 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.Arrays;

View File

@ -29,12 +29,9 @@ import java.util.concurrent.Future;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.security.Principal;
import java.security.Provider;
import java.security.Security;
import java.security.KeyStoreException;
@ -43,7 +40,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.net.InetSocketAddress;
import javax.net.ssl.SSLContext;
@ -60,11 +56,8 @@ import javax.net.ssl.SSLHandshakeException;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import com.wolfssl.WolfSSL;
import com.wolfssl.WolfSSLContext;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLProvider;
@ -311,6 +304,7 @@ public class WolfSSLSessionTest {
* ClassCastException */
try {
X509Certificate[] xCerts = (X509Certificate[])certs;
assertNotNull(xCerts);
} catch (ClassCastException e) {
error("\t\t... failed");
fail("getPeerCertificates() did not return array of type " +

View File

@ -23,8 +23,6 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.ArrayList;
@ -53,7 +51,6 @@ import java.security.KeyStoreException;
import java.security.KeyManagementException;
import java.security.NoSuchProviderException;
import java.security.NoSuchAlgorithmException;
import java.net.UnknownHostException;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLProvider;
@ -165,11 +162,7 @@ public class WolfSSLSocketFactoryTest {
SSLSocketFactory sf =
new com.wolfssl.provider.jsse.WolfSSLSocketFactory();
if (sf == null) {
System.out.println("\t\t\t... failed");
fail("SSLSocketFactory.getDefault() failed");
}
assertNotNull(sf);
System.out.println("\t\t\t... passed");
}

View File

@ -23,15 +23,11 @@ package com.wolfssl.provider.jsse.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@ -50,20 +46,16 @@ import java.net.Socket;
import java.net.ServerSocket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.net.ConnectException;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
@ -1178,6 +1170,7 @@ public class WolfSSLSocketTest {
es.shutdown();
serverFuture.get();
serverSock.close();
System.out.println("\t... passed");
}
@ -2583,6 +2576,7 @@ public class WolfSSLSocketTest {
/* connect to invalid host/port, expect java.net.ConnectException.
* we do not expect anything to be running at localhost:12345 */
SSLSocket cs = (SSLSocket)sf.createSocket("localhost", 12345);
assertNotNull(cs);
} catch (ConnectException ce) {
/* expected */
} catch (Exception e) {
@ -2820,9 +2814,7 @@ public class WolfSSLSocketTest {
public void testSocketCloseInterruptsWrite() throws Exception {
String protocol = null;
SSLServerSocketFactory ssf = null;
SSLServerSocket ss = null;
SSLSocketFactory sf = null;
boolean passed = false;
System.out.print("\tTesting close/write interrupt");
@ -2952,9 +2944,7 @@ public class WolfSSLSocketTest {
int ret = 0;
String protocol = null;
SSLServerSocketFactory ssf = null;
SSLServerSocket ss = null;
SSLSocketFactory sf = null;
boolean passed = false;
System.out.print("\tTesting close/read interrupt");

View File

@ -23,12 +23,10 @@ package com.wolfssl.provider.jsse.test;
import com.wolfssl.WolfSSL;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLProvider;
import com.wolfssl.provider.jsse.WolfSSLContext;
import com.wolfssl.provider.jsse.WolfSSLTrustX509;
import java.util.List;
import java.util.ArrayList;
import java.util.Enumeration;
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
@ -40,7 +38,6 @@ import java.io.PrintWriter;
import java.time.Instant;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
@ -180,9 +177,7 @@ public class WolfSSLTrustX509Test {
public void testUseBeforeInit()
throws NoSuchProviderException, NoSuchAlgorithmException {
TrustManagerFactory tmf;
TrustManager[] tm;
KeyManagerFactory kmf;
KeyManager[] km;
System.out.print("\tTesting use before init()");
@ -200,7 +195,7 @@ public class WolfSSLTrustX509Test {
}
try {
tm = tmf.getTrustManagers();
tmf.getTrustManagers();
error("\t... failed");
fail("getTrustManagers() before init() did not throw an error");
} catch (IllegalStateException e) {
@ -215,7 +210,7 @@ public class WolfSSLTrustX509Test {
}
try {
km = kmf.getKeyManagers();
kmf.getKeyManagers();
error("\t... failed");
fail("getKeyManagers() before init() did not throw an error");
} catch (IllegalStateException e) {
@ -1869,7 +1864,6 @@ public class WolfSSLTrustX509Test {
/* Fail if client or server encountered exception */
Exception srvException = server.getException();
Exception cliException = client.getException();
if (srvException == null) {
throw new Exception("Expecting exception but did not get one");

View File

@ -419,10 +419,7 @@ public class WolfSSLX509Test {
SSLEngine server;
SSLEngine client;
String cipher = null;
int ret, i;
String[] ciphers;
String certType;
int ret;
SSLContext ctxClient;
SSLContext ctxServer;
System.out.print("\tTesting x509 getters");

View File

@ -22,9 +22,6 @@
package com.wolfssl.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import com.wolfssl.WolfSSLException;
import com.wolfssl.WolfCryptECC;

View File

@ -22,9 +22,6 @@
package com.wolfssl.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import com.wolfssl.WolfSSLException;
import com.wolfssl.WolfCryptRSA;

View File

@ -23,8 +23,6 @@ package com.wolfssl.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.io.File;

View File

@ -34,7 +34,6 @@ import java.util.logging.Logger;
import java.time.Instant;
import java.time.Duration;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
@ -48,8 +47,6 @@ import java.security.NoSuchAlgorithmException;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import com.wolfssl.WolfSSL;

View File

@ -23,8 +23,6 @@ package com.wolfssl.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import com.wolfssl.WolfSSL;

View File

@ -36,11 +36,9 @@ import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.CountDownLatch;
import java.util.Arrays;
import java.nio.ByteBuffer;
import com.wolfssl.WolfSSL;
@ -458,14 +456,14 @@ public class WolfSSLSessionTest {
public void test_WolfSSLSession_getPskIdentity()
throws WolfSSLJNIException, WolfSSLException {
String identity = null;
WolfSSLSession ssl = null;
System.out.print("\tgetPskIdentity()");
try {
ssl = new WolfSSLSession(ctx);
identity = ssl.getPskIdentity();
/* Not checking return, just that we don't throw an exception */
ssl.getPskIdentity();
} catch (IllegalStateException e) {
System.out.println("\t\t... failed");
@ -690,6 +688,7 @@ public class WolfSSLSessionTest {
/* setup library, context, session, socket */
sslLib = new WolfSSL();
assertNotNull(sslLib);
sslCtx = new WolfSSLContext(WolfSSL.TLSv1_2_ClientMethod());
sslCtx.setVerify(WolfSSL.SSL_VERIFY_NONE, null);
ssl = new WolfSSLSession(sslCtx);
@ -772,6 +771,7 @@ public class WolfSSLSessionTest {
/* setup library, context, session, socket */
sslLib = new WolfSSL();
assertNotNull(sslLib);
sslCtx = new WolfSSLContext(WolfSSL.TLSv1_2_ClientMethod());
sslCtx.setVerify(WolfSSL.SSL_VERIFY_NONE, null);
ssl = new WolfSSLSession(sslCtx);
@ -834,12 +834,10 @@ public class WolfSSLSessionTest {
public void test_WolfSSLSession_useSecureRenegotiation()
throws WolfSSLJNIException {
int ret, err;
int ret;
WolfSSL sslLib = null;
WolfSSLContext sslCtx = null;
WolfSSLSession ssl = null;
Socket sock = null;
byte[] sessionID = null;
System.out.print("\tTesting useSecureRenegotiation()");
@ -847,6 +845,7 @@ public class WolfSSLSessionTest {
/* setup library, context, session, socket */
sslLib = new WolfSSL();
assertNotNull(sslLib);
sslCtx = new WolfSSLContext(WolfSSL.TLSv1_2_ClientMethod());
sslCtx.setVerify(WolfSSL.SSL_VERIFY_NONE, null);
ssl = new WolfSSLSession(sslCtx);
@ -906,6 +905,7 @@ public class WolfSSLSessionTest {
/* setup library, context, session, socket */
sslLib = new WolfSSL();
assertNotNull(sslLib);
sslCtx = new WolfSSLContext(WolfSSL.TLSv1_3_ClientMethod());
sslCtx.setVerify(WolfSSL.SSL_VERIFY_NONE, null);
ssl = new WolfSSLSession(sslCtx);
@ -1027,7 +1027,7 @@ public class WolfSSLSessionTest {
/* Start server */
try {
ExecutorService es = Executors.newSingleThreadExecutor();
Future<Void> serverFuture = es.submit(new Callable<Void>() {
es.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
int ret;
@ -1119,20 +1119,19 @@ public class WolfSSLSessionTest {
fail();
} finally {
/* Free resources */
if (cliSes != null) {
cliSes.freeSSL();
}
if (cliSock != null) {
cliSock.close();
}
}
/* Free resources */
if (srvSocket != null) {
srvSocket.close();
}
if (srvCtx != null) {
srvCtx.free();
if (srvSocket != null) {
srvSocket.close();
}
if (srvCtx != null) {
srvCtx.free();
}
}
} finally {
@ -1210,7 +1209,7 @@ public class WolfSSLSessionTest {
/* Start server, handles 1 resumption */
try {
ExecutorService es = Executors.newSingleThreadExecutor();
Future<Void> serverFuture = es.submit(new Callable<Void>() {
es.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
int ret;
@ -1389,6 +1388,7 @@ public class WolfSSLSessionTest {
fail();
} finally {
/* Free resources */
if (sessionPtr != 0) {
WolfSSLSession.freeSession(sessionPtr);
}
@ -1401,14 +1401,12 @@ public class WolfSSLSessionTest {
if (cliSock != null) {
cliSock.close();
}
}
/* Free resources */
if (srvSocket != null) {
srvSocket.close();
}
if (srvCtx != null) {
srvCtx.free();
if (srvSocket != null) {
srvSocket.close();
}
if (srvCtx != null) {
srvCtx.free();
}
}
System.out.println("\t... passed");
@ -1425,9 +1423,6 @@ public class WolfSSLSessionTest {
private int cliToSrvUsed = 0;
private int srvToCliUsed = 0;
private int CLIENT_END = 1;
private int SERVER_END = 2;
private final Object cliLock = new Object();
private final Object srvLock = new Object();
@ -1634,7 +1629,7 @@ public class WolfSSLSessionTest {
/* Initialize library */
WolfSSL lib = new WolfSSL();
assertNotNull(lib);
/* Create ServerSocket first to get ephemeral port */
final ServerSocket srvSocket = new ServerSocket(0);

View File

@ -23,8 +23,6 @@ package com.wolfssl.test;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.*;
import java.util.Arrays;