diff --git a/.github/workflows/android_gradle.yml b/.github/workflows/android_gradle.yml
new file mode 100644
index 00000000..af67147d
--- /dev/null
+++ b/.github/workflows/android_gradle.yml
@@ -0,0 +1,52 @@
+name: Android Gradle Build test logic
+
+on:
+ workflow_call:
+ inputs:
+ os:
+ required: true
+ type: string
+ jdk_distro:
+ required: true
+ type: string
+ jdk_version:
+ required: true
+ type: string
+
+jobs:
+ build_wolfssljni:
+ runs-on: ${{ inputs.os }}
+ steps:
+ - name: Clone wolfssljni
+ uses: actions/checkout@v4
+
+ # Clone native wolfSSL
+ - name: Clone native wolfSSL
+ uses: actions/checkout@v4
+ with:
+ repository: 'wolfssl/wolfssl'
+ path: IDE/Android/app/src/main/cpp/wolfssl
+
+ # Copy options.h.in to blank options.h
+ - name: Create blank options.h
+ run: cp IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h.in IDE/Android/app/src/main/cpp/wolfssl/wolfssl/options.h
+
+ # Setup Java
+ - name: Setup java
+ uses: actions/setup-java@v4
+ with:
+ distribution: ${{ inputs.jdk_distro }}
+ java-version: ${{ inputs.jdk_version }}
+
+ # Gradle assembleDebug
+ - name: Gradle assembleDebug
+ run: cd IDE/Android && ls && ./gradlew assembleDebug
+
+ # Gradle assembleDebugUnitTest
+ - name: Gradle assembleDebugUnitTest
+ run: cd IDE/Android && ls && ./gradlew assembleDebugUnitTest
+
+ # Gradle assembleDebugAndroidTest
+ - name: Gradle assembleDebugAndroidTest
+ run: cd IDE/Android && ls && ./gradlew assembleDebugAndroidTest
+
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a8b489a1..e69cbaf9 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -118,3 +118,18 @@ jobs:
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}
+ # ----------------------- Android Gradle build ------------------------
+ # Run Android gradle build over PR code, only running on Linux with one
+ # JDK/version for now.
+ android-gradle:
+ strategy:
+ matrix:
+ os: [ 'ubuntu-latest' ]
+ jdk_version: [ '21' ]
+ name: Android Gradle (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
+ uses: ./.github/workflows/android_gradle.yml
+ with:
+ os: ${{ matrix.os }}
+ jdk_distro: "zulu"
+ jdk_version: ${{ matrix.jdk_version }}
+
diff --git a/IDE/Android/.idea/misc.xml b/IDE/Android/.idea/misc.xml
index 547df141..6d2b9cfd 100644
--- a/IDE/Android/.idea/misc.xml
+++ b/IDE/Android/.idea/misc.xml
@@ -13,4 +13,11 @@
+
+
+
\ No newline at end of file
diff --git a/IDE/Android/app/build.gradle b/IDE/Android/app/build.gradle
index 742f97cf..870108bb 100644
--- a/IDE/Android/app/build.gradle
+++ b/IDE/Android/app/build.gradle
@@ -1,11 +1,14 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 30
+ compileSdk 33
defaultConfig {
applicationId "com.example.wolfssl"
- minSdkVersion 30
- targetSdkVersion 30
+ /* Min SDK should stay at 24 to detect if we try to use newer APIs
+ * than were available in that Android SDK. We have users who are still
+ on SDK 24 (ref ZD 18311) */
+ minSdkVersion 24
+ targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -15,6 +18,10 @@ android {
}
}
}
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
+ }
buildTypes {
release {
minifyEnabled false
@@ -26,14 +33,18 @@ android {
path "src/main/cpp/CMakeLists.txt"
}
}
+ sourceSets {
+ main.java.srcDirs += '../../src/java'
+ test.java.srcDirs += '../../src/test'
+ }
namespace 'com.example.wolfssl'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
- implementation 'com.android.support.constraint:constraint-layout:1.1.3'
- testImplementation 'junit:junit:4.12'
+ implementation 'com.android.support.constraint:constraint-layout:2.0.4'
+ testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
diff --git a/IDE/Android/app/src/main/AndroidManifest.xml b/IDE/Android/app/src/main/AndroidManifest.xml
index 237679f2..c3d43e9f 100644
--- a/IDE/Android/app/src/main/AndroidManifest.xml
+++ b/IDE/Android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
-
+
diff --git a/IDE/Android/app/src/main/cpp/CMakeLists.txt b/IDE/Android/app/src/main/cpp/CMakeLists.txt
index bbae83bc..d06b7fe6 100644
--- a/IDE/Android/app/src/main/cpp/CMakeLists.txt
+++ b/IDE/Android/app/src/main/cpp/CMakeLists.txt
@@ -11,6 +11,10 @@ project("wolfssljni-gradle" C ASM)
set(wolfssljni_DIR ${CMAKE_SOURCE_DIR}/../../../../../../)
set(wolfssl_DIR ${CMAKE_SOURCE_DIR}/wolfssl/)
+# set warnings as errors, used in this example project but may be different
+# in production apps/environments.
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
+
# ------------------------- wolfSSL Normal vs. FIPS Ready Selection --------------------------------
# Select if wolfSSL is normal ("normal") or FIPS Ready ("fipsready")
# wolfSSL FIPS Ready is available for download on the wolfssl.com download page. For more
@@ -222,7 +226,10 @@ list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_bn.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_asn1.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_certman.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_crypto.c)
+list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_load.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_misc.c)
+list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_p7p12.c)
+list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/ssl_sess.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509.c)
list(REMOVE_ITEM TLS_SOURCES ${wolfssl_DIR}/src/x509_str.c)
diff --git a/IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java b/IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java
index 9080f6f3..e3ab2485 100644
--- a/IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java
+++ b/IDE/Android/app/src/main/java/com/example/wolfssl/MainActivity.java
@@ -22,10 +22,6 @@
package com.example.wolfssl;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
@@ -35,17 +31,11 @@
import com.wolfssl.WolfSSL;
import com.wolfssl.WolfSSLException;
import com.wolfssl.provider.jsse.WolfSSLProvider;
-import com.wolfssl.provider.jsse.WolfSSLX509;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.Security;
-import java.security.cert.CertificateException;
public class MainActivity extends AppCompatActivity {
@@ -55,7 +45,7 @@ public void onClick(View v) {
TextView tv = (TextView) findViewById(R.id.sample_text);
try {
- testLoadCert(tv);
+ testFindProvider(tv);
} catch (Exception e) {
e.printStackTrace();
}
@@ -72,23 +62,11 @@ protected void onCreate(Bundle savedInstanceState) {
TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText("wolfSSL JNI Android Studio Example App");
-
- if (!Environment.isExternalStorageManager()) {
- Intent intent = new Intent(
- Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
- Uri uri = Uri.fromParts("package", getPackageName(), null);
- intent.setData(uri);
- startActivity(intent);
- }
}
- public void testLoadCert(TextView tv)
+ public void testFindProvider(TextView tv)
throws NoSuchProviderException, NoSuchAlgorithmException,
- KeyStoreException, IOException, CertificateException,
WolfSSLException {
- String file = "/sdcard/examples/provider/all.bks";
- WolfSSLX509 x509;
- KeyStore ks;
WolfSSL.loadLibrary();
@@ -100,11 +78,8 @@ public void testLoadCert(TextView tv)
System.out.println("Unable to find wolfJSSE provider");
return;
}
+ else {
- ks = KeyStore.getInstance("BKS");
- ks.load(new FileInputStream(file), "wolfSSL test".toCharArray());
-
- x509 = new WolfSSLX509(ks.getCertificate("server").getEncoded());
- tv.setText("Server Certificate Found:\n" + x509.toString());
+ }
}
-}
+}
\ No newline at end of file
diff --git a/IDE/Android/app/src/main/res/layout/activity_main.xml b/IDE/Android/app/src/main/res/layout/activity_main.xml
index 1e49ea6b..e9e3b412 100644
--- a/IDE/Android/app/src/main/res/layout/activity_main.xml
+++ b/IDE/Android/app/src/main/res/layout/activity_main.xml
@@ -8,9 +8,13 @@
+ android:text="Test Provider Lookup"
+ app:layout_constraintBottom_toTopOf="@+id/sample_text"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
> altNames = null;
+ private ArrayList> altNames = null;
/* Public key types used for certificate generation, mirrored from
* native enum in wolfssl/openssl/evp.h */
@@ -1463,10 +1466,10 @@ public Collection> getSubjectAltNames()
synchronized (x509Lock) {
if (this.altNames != null) {
/* already gathered, return cached version */
- return this.altNames;
+ return Collections.unmodifiableCollection(this.altNames);
}
- Collection> names = new ArrayList>();
+ ArrayList> names = new ArrayList>();
String nextAltName = X509_get_next_altname(this.x509Ptr);
while (nextAltName != null) {
@@ -1480,9 +1483,9 @@ public Collection> getSubjectAltNames()
}
/* cache altNames collection for later use */
- this.altNames = Collections.unmodifiableCollection(names);
+ this.altNames = names;
- return this.altNames;
+ return Collections.unmodifiableCollection(this.altNames);
}
}
diff --git a/src/java/com/wolfssl/WolfSSLException.java b/src/java/com/wolfssl/WolfSSLException.java
index 29ca9137..21e2021d 100644
--- a/src/java/com/wolfssl/WolfSSLException.java
+++ b/src/java/com/wolfssl/WolfSSLException.java
@@ -26,6 +26,9 @@
*/
public class WolfSSLException extends Exception {
+ /* Exception class is serializable */
+ private static final long serialVersionUID = 1L;
+
/**
* Create WolfSSLException with reason String
*
diff --git a/src/java/com/wolfssl/WolfSSLJNIException.java b/src/java/com/wolfssl/WolfSSLJNIException.java
index 71157b8a..5e6519a7 100644
--- a/src/java/com/wolfssl/WolfSSLJNIException.java
+++ b/src/java/com/wolfssl/WolfSSLJNIException.java
@@ -26,6 +26,9 @@
*/
public class WolfSSLJNIException extends Exception {
+ /* Exception class is serializable */
+ private static final long serialVersionUID = 1L;
+
/**
* Create WolfSSLJNIException with reason String
*
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java b/src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java
index d6a760e7..8ac59527 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLAuthStore.java
@@ -97,9 +97,9 @@ protected WolfSSLAuthStore(KeyManager[] keyman, TrustManager[] trustman,
store = new SessionStore<>(defaultCacheSize);
}
this.serverCtx = new WolfSSLSessionContext(
- this, defaultCacheSize, WolfSSL.WOLFSSL_SERVER_END);
+ defaultCacheSize, WolfSSL.WOLFSSL_SERVER_END);
this.clientCtx = new WolfSSLSessionContext(
- this, defaultCacheSize, WolfSSL.WOLFSSL_CLIENT_END);
+ defaultCacheSize, WolfSSL.WOLFSSL_CLIENT_END);
}
/**
@@ -251,6 +251,7 @@ protected String getCertAlias() {
* @return pointer to the context set
*/
protected WolfSSLSessionContext getServerContext() {
+ this.serverCtx.setWolfSSLAuthStore(this);
return this.serverCtx;
}
@@ -260,6 +261,7 @@ protected WolfSSLSessionContext getServerContext() {
* @return pointer to the context set
*/
protected WolfSSLSessionContext getClientContext() {
+ this.clientCtx.setWolfSSLAuthStore(this);
return this.clientCtx;
}
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLDebug.java b/src/java/com/wolfssl/provider/jsse/WolfSSLDebug.java
index 973b48a7..6df38938 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLDebug.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLDebug.java
@@ -84,7 +84,9 @@ public static void print(String string) {
* @param tag level of debug message i.e. WolfSSLDebug.INFO
* @param string message to be printed out
*/
- public static synchronized void log(Class cl, String tag, String string) {
+ public static synchronized void log(Class cl, String tag,
+ String string) {
+
if (DEBUG) {
System.out.println(new Timestamp(new java.util.Date().getTime()) +
" [wolfJSSE " + tag + ": TID " +
@@ -102,8 +104,9 @@ public static synchronized void log(Class cl, String tag, String string) {
* @param in byte array to be printed as hex
* @param sz number of bytes from in array to be printed
*/
- public static synchronized void logHex(Class cl, String tag, String label,
- byte[] in, int sz) {
+ public static synchronized void logHex(Class cl, String tag,
+ String label, byte[] in, int sz) {
+
if (DEBUG) {
int i = 0, j = 0;
int printSz = 0;
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java b/src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java
index 02d3a312..dae87a6e 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java
@@ -36,7 +36,6 @@
import java.util.Arrays;
import java.util.ArrayList;
import java.util.logging.Level;
-import java.util.logging.Logger;
import java.security.cert.CertificateEncodingException;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
@@ -76,6 +75,10 @@ public class WolfSSLEngine extends SSLEngine {
/* Does TLS handshake need initialization */
private boolean needInit = true;
+ private final Object initLock = new Object();
+
+ /* Have cert/key been loaded? */
+ private boolean certKeyLoaded = false;
private boolean inBoundOpen = true;
private boolean outBoundOpen = true;
@@ -163,23 +166,14 @@ protected WolfSSLEngine(com.wolfssl.WolfSSLContext ctx,
this.ctx = ctx;
this.authStore = auth;
this.params = params.copy();
+
try {
initSSL();
} catch (WolfSSLJNIException ex) {
- Logger.getLogger(WolfSSLEngine.class.getName()).log(Level.SEVERE,
- null, ex);
- throw new WolfSSLException("Error with init");
+ throw new WolfSSLException("Error with WolfSSLEngine init");
}
this.engineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
this.params);
-
- try {
- this.engineHelper.LoadKeyAndCertChain(null, this);
- } catch (CertificateEncodingException | IOException e) {
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "failed to load private key and/or cert chain");
- throw new WolfSSLException(e);
- }
}
/**
@@ -199,22 +193,62 @@ protected WolfSSLEngine(com.wolfssl.WolfSSLContext ctx,
this.ctx = ctx;
this.authStore = auth;
this.params = params.copy();
+
try {
initSSL();
} catch (WolfSSLJNIException ex) {
- Logger.getLogger(WolfSSLEngine.class.getName()).log(Level.SEVERE,
- null, ex);
- throw new WolfSSLException("Error with init");
+ throw new WolfSSLException("Error with WolfSSLEngine init");
}
this.engineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
this.params, port, host);
+ }
+
+ /**
+ * Loads the key and certificate for this SSLEngine if not loaded yet.
+ *
+ * @throws SSLException on error
+ */
+ private synchronized void LoadCertAndKey() throws SSLException {
+
+ /* Load cert and key */
+ if (certKeyLoaded) {
+ return;
+ }
try {
this.engineHelper.LoadKeyAndCertChain(null, this);
- } catch (CertificateEncodingException | IOException e) {
+ } catch (CertificateEncodingException | IOException |
+ WolfSSLException e) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"failed to load private key and/or cert chain");
- throw new WolfSSLException(e);
+ throw new SSLException(e);
+ }
+ }
+
+ /**
+ * Initialize this WolfSSLEngine prior to handshaking.
+ *
+ * Internal method, should be called before any handshake.
+ *
+ * This logic is not included directly in WolfSSLEngine constructors
+ * to avoid possible 'this' escape before subclass is fully initialized
+ * when using 'this' in LoadKeyAndCertChain().
+ *
+ * @throws SSLException if initialization fails
+ */
+ private void checkAndInitSSLEngine() throws SSLException {
+
+ synchronized (initLock) {
+
+ if (!needInit) {
+ return;
+ }
+
+ LoadCertAndKey();
+
+ this.engineHelper.initHandshake(this);
+ needInit = false;
+ closed = false; /* opened a connection */
}
}
@@ -513,6 +547,7 @@ private synchronized int SendAppData(ByteBuffer[] in, int ofst, int len)
@Override
public synchronized SSLEngineResult wrap(ByteBuffer in, ByteBuffer out)
throws SSLException {
+
if (in == null) {
throw new SSLException("SSLEngine.wrap() bad arguments");
}
@@ -523,6 +558,7 @@ public synchronized SSLEngineResult wrap(ByteBuffer in, ByteBuffer out)
@Override
public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
ByteBuffer out) throws SSLException {
+
int ret = 0, i;
int produced = 0;
int consumed = 0;
@@ -608,9 +644,7 @@ public synchronized SSLEngineResult wrap(ByteBuffer[] in, int ofst, int len,
}
if (needInit) {
- this.engineHelper.initHandshake(this);
- needInit = false;
- closed = false; /* opened a connection */
+ checkAndInitSSLEngine();
}
synchronized (netDataLock) {
@@ -815,10 +849,12 @@ private synchronized int RecvAppData(ByteBuffer[] out, int ofst, int length)
/* In 0 and ZERO_RETURN cases we may have gotten a
* close_notify alert, check on shutdown status */
case WolfSSL.SSL_ERROR_ZERO_RETURN:
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "RecvAppData(), got ZERO_RETURN");
- /* Fall through on purpose */
case 0:
+ if (err == WolfSSL.SSL_ERROR_ZERO_RETURN) {
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "RecvAppData(), got ZERO_RETURN");
+ }
+
/* check if is shutdown message */
synchronized (ioLock) {
if (ssl.getShutdown() ==
@@ -877,6 +913,7 @@ private synchronized int RecvAppData(ByteBuffer[] out, int ofst, int length)
@Override
public synchronized SSLEngineResult unwrap(ByteBuffer in, ByteBuffer out)
throws SSLException {
+
if (out == null) {
throw new IllegalArgumentException(
"SSLEngine.unwrap() bad arguments");
@@ -888,6 +925,7 @@ public synchronized SSLEngineResult unwrap(ByteBuffer in, ByteBuffer out)
@Override
public synchronized SSLEngineResult unwrap(ByteBuffer in, ByteBuffer[] out,
int ofst, int length) throws SSLException {
+
int i, ret = 0, sz = 0, err = 0;
int inPosition = 0;
int inRemaining = 0;
@@ -910,7 +948,8 @@ public synchronized SSLEngineResult unwrap(ByteBuffer in, ByteBuffer[] out,
for (i = ofst; i < length; ++i) {
if (out[i] == null) {
- throw new IllegalArgumentException("SSLEngine.unwrap() bad arguments");
+ throw new IllegalArgumentException(
+ "SSLEngine.unwrap() bad arguments");
}
if (out[i].isReadOnly()) {
@@ -996,9 +1035,7 @@ else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP &&
else {
if (needInit) {
- this.engineHelper.initHandshake(this);
- needInit = false;
- closed = false;
+ checkAndInitSSLEngine();
}
if (outBoundOpen == false) {
@@ -1367,7 +1404,7 @@ public String[] getEnabledCipherSuites() {
}
@Override
- public void setEnabledCipherSuites(String[] suites) {
+ public synchronized void setEnabledCipherSuites(String[] suites) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered setEnabledCipherSuites()");
this.engineHelper.setCiphers(suites);
@@ -1398,6 +1435,14 @@ public synchronized void setEnabledProtocols(String[] protocols) {
public synchronized SSLSession getSession() {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered getSession()");
+
+ try {
+ /* Need cert loaded for getSession().getLocalCertificates() */
+ LoadCertAndKey();
+ } catch (SSLException e) {
+ return null;
+ }
+
return this.engineHelper.getSession();
}
@@ -1500,8 +1545,7 @@ else if (!this.needInit && !this.handshakeFinished) {
if (needInit == true) {
/* will throw SSLHandshakeException if session creation is
not allowed */
- this.engineHelper.initHandshake(this);
- needInit = false;
+ checkAndInitSSLEngine();
}
try {
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLParametersHelper.java b/src/java/com/wolfssl/provider/jsse/WolfSSLParametersHelper.java
index 4ffb05fc..2709d358 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLParametersHelper.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLParametersHelper.java
@@ -122,7 +122,7 @@ protected static SSLParameters decoupleParams(WolfSSLParameters in) {
/* load WolfSSLJDK8Helper at runtime, not compiled on older JDKs */
Class> cls = Class.forName("com.wolfssl.provider.jsse.WolfSSLJDK8Helper");
Object obj = cls.getConstructor().newInstance();
- Class[] paramList = new Class[3];
+ Class>[] paramList = new Class>[3];
paramList[0] = javax.net.ssl.SSLParameters.class;
paramList[1] = java.lang.reflect.Method.class;
paramList[2] = com.wolfssl.provider.jsse.WolfSSLParameters.class;
@@ -200,7 +200,7 @@ protected static void importParams(SSLParameters in,
/* load WolfSSLJDK8Helper at runtime, not compiled on older JDKs */
Class> cls = Class.forName("com.wolfssl.provider.jsse.WolfSSLJDK8Helper");
Object obj = cls.getConstructor().newInstance();
- Class[] paramList = new Class[2];
+ Class>[] paramList = new Class>[2];
paramList[0] = javax.net.ssl.SSLParameters.class;
paramList[1] = com.wolfssl.provider.jsse.WolfSSLParameters.class;
Method mth = null;
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLProvider.java b/src/java/com/wolfssl/provider/jsse/WolfSSLProvider.java
index d47cfadb..eeae927f 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLProvider.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLProvider.java
@@ -32,6 +32,8 @@
*/
public final class WolfSSLProvider extends Provider {
+ private static final long serialVersionUID = 1L;
+
/* Keep one static reference to native wolfSSL library across
* all WolfSSLProvider objects. */
private static WolfSSL sslLib = null;
@@ -164,7 +166,7 @@ public void setDevId(int devId) throws WolfSSLException {
/* Store devId into static WolfSSL variable, used by
* WolfSSLContext (SSLContext) */
- sslLib.devId = devId;
+ WolfSSL.devId = devId;
}
@@ -190,7 +192,7 @@ public void registerDevId(int devId) throws WolfSSLException {
/* Call native JNI entry point to register native wolfSSL
* CryptoDevice callback function. See native JNI function in
* native/com_wolfssl_WolfSSL.c */
- ret = sslLib.cryptoCbRegisterDevice(devId);
+ ret = WolfSSL.cryptoCbRegisterDevice(devId);
if (ret != 0) {
throw new WolfSSLException(
"Error registering native wolfSSL crypto callback, " +
@@ -215,7 +217,7 @@ public void unRegisterDevId(int devId) throws WolfSSLException {
/* Call native JNI entry point to unregister native wolfSSL
* CryptoDevice callback function. See native JNI function in
* native/com_wolfssl_WolfSSL.c */
- ret = sslLib.cryptoCbUnRegisterDevice(devId);
+ ret = WolfSSL.cryptoCbUnRegisterDevice(devId);
if (ret != 0) {
throw new WolfSSLException(
"Error unregistering native wolfSSL crypto callback, " +
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLSessionContext.java b/src/java/com/wolfssl/provider/jsse/WolfSSLSessionContext.java
index 9d583704..a4991ff2 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLSessionContext.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLSessionContext.java
@@ -24,6 +24,7 @@
import java.util.Enumeration;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
+import com.wolfssl.WolfSSL;
/**
* WolfSSLSessionContext class
@@ -31,10 +32,27 @@
* @author wolfSSL Inc.
*/
public class WolfSSLSessionContext implements SSLSessionContext {
- private WolfSSLAuthStore store;
- private int sesTimout;
- private int sesCache;
- private int side;
+ private WolfSSLAuthStore store = null;
+ private int sesTimout = 0;
+ private int sesCache = 0;
+ private int side = WolfSSL.WOLFSSL_CLIENT_END;
+
+ /**
+ * Create new WolfSSLSessionContext
+ *
+ * WolfSSLAuthStore not given as parameter in this constructor, caller
+ * should explicitly set with WolfSSLSessionContext.setWolfSSLAuthStore().
+ *
+ * @param in WolfSSLAuthStore object to use with this context
+ * @param defaultCacheSize default session cache size
+ * @param side client or server side. Either WolfSSL.WOLFSSL_CLIENT_END or
+ * WolfSSL.WOLFSSL_SERVER_END
+ */
+ public WolfSSLSessionContext(int defaultCacheSize, int side) {
+ this.sesCache = defaultCacheSize;
+ this.sesTimout = 86400; /* this is the default value in SunJSSE too */
+ this.side = side;
+ }
/**
* Create new WolfSSLSessionContext
@@ -52,15 +70,24 @@ public WolfSSLSessionContext(WolfSSLAuthStore in, int defaultCacheSize,
this.side = side;
}
+ public void setWolfSSLAuthStore(WolfSSLAuthStore store) {
+ this.store = store;
+ }
@Override
public SSLSession getSession(byte[] sessionId) {
+ if (store == null) {
+ return null;
+ }
return store.getSession(sessionId, side);
}
@Override
public Enumeration getIds() {
+ if (store == null) {
+ return null;
+ }
return store.getAllIDs(side);
}
@@ -70,7 +97,9 @@ public void setSessionTimeout(int in) throws IllegalArgumentException {
this.sesTimout = in;
/* check for any new timeouts after timeout has been set */
- store.updateTimeouts(in, this.side);
+ if (store != null) {
+ store.updateTimeouts(in, this.side);
+ }
}
@Override
@@ -88,7 +117,7 @@ public void setSessionCacheSize(int in)
}
/* resize store array if needed */
- if (this.sesCache != in) {
+ if ((store != null) && (this.sesCache != in)) {
store.resizeCache(in, this.side);
}
this.sesCache = in;
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java b/src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java
index 8f17bdaa..1d5f2992 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLSocket.java
@@ -89,6 +89,8 @@ public class WolfSSLSocket extends SSLSocket {
protected volatile boolean handshakeComplete = false;
/** Connection to peer has closed */
protected volatile boolean connectionClosed = false;
+ /** Flag representing if I/O callbacks have been set */
+ private boolean ioCallbacksSet = false;
/* lock for handshakInitCalled and handshakeComplete */
private final Object handshakeLock = new Object();
@@ -100,6 +102,10 @@ public class WolfSSLSocket extends SSLSocket {
/* lock for get/set of SO timeout */
private final Object timeoutLock = new Object();
+ /* lock and status for WolfSSLSocket initialization */
+ private boolean isInitialized = false;
+ private final Object initLock = new Object();
+
/** ALPN selector callback, if set */
protected BiFunction, String> alpnSelector = null;
@@ -130,16 +136,12 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- /* don't call setFd() yet since we don't have a connected socket */
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
this.params);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
@@ -174,16 +176,12 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- setFd();
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, port, host);
+ this.params, port, host);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
@@ -221,16 +219,12 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- setFd();
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, port, address);
+ this.params, port, address);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
@@ -265,16 +259,12 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- setFd();
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, port, host);
+ this.params, port, host);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
@@ -312,16 +302,12 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- setFd();
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, port, host);
+ this.params, port, host);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
@@ -373,20 +359,261 @@ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
try {
initSSL();
- setFd();
- /* get helper class for common methods */
EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, port, host);
+ this.params, port, host);
EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(this.socket, null);
- } catch (WolfSSLException | CertificateEncodingException |
- IOException e) {
+ } catch (WolfSSLException e) {
throw new IOException(e);
}
}
+ /**
+ * Create new WolfSSLSocket object layered over an existing Socket.
+ *
+ * @param context WolfSSLContext to use with this SSLSocket
+ * @param authStore WolfSSLAuthStore to use with this SSLSocket
+ * @param params WolfSSLParameters to use with this SSLSocket
+ * @param clientMode true if this is a client socket, otherwise false
+ * @param s existing connected Socket
+ * @param autoClose automatically close wrapped Socket when finished
+ *
+ * @throws IOException if initialization fails
+ */
+ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
+ WolfSSLAuthStore authStore, WolfSSLParameters params,
+ boolean clientMode, Socket s, boolean autoClose)
+ throws IOException {
+
+ super();
+ this.ctx = context;
+ this.authStore = authStore;
+ this.params = params.copy();
+ this.socket = s;
+ this.autoClose = autoClose;
+
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "creating new WolfSSLSocket(clientMode: " +
+ String.valueOf(clientMode) + ", Socket, autoClose: " +
+ String.valueOf(autoClose) + ")");
+
+ if (!s.isConnected()) {
+ throw new IOException("Socket is not connected");
+ }
+
+ try {
+ initSSL();
+
+ EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
+ this.params, s.getPort(), s.getInetAddress());
+ EngineHelper.setUseClientMode(clientMode);
+
+ } catch (WolfSSLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ /**
+ * Create new WolfSSLSocket object layered over an existing Socket,
+ * only a server mode Socket. Use pre-consumed InputStream data
+ * if provided.
+ *
+ * @param context WolfSSLContext to use with this SSLSocket
+ * @param authStore WolfSSLAuthStore to use with this SSLSocket
+ * @param params WolfSSLParameters to use with this SSLSocket
+ * @param s existing connected Socket
+ * @param consumed pre-consumed Socket data to use for this SSLSocket
+ * @param autoClose automatically close wrapped Socket when finished
+ *
+ * @throws IOException if initialization fails
+ */
+ public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
+ WolfSSLAuthStore authStore, WolfSSLParameters params, Socket s,
+ InputStream consumed, boolean autoClose) throws IOException {
+
+ super();
+ this.ctx = context;
+ this.authStore = authStore;
+ this.params = params.copy();
+ this.socket = s;
+ this.autoClose = autoClose;
+
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "creating new WolfSSLSocket(Socket, InputStream, autoClose: " +
+ String.valueOf(autoClose) + ")");
+
+ if (s == null ) {
+ throw new NullPointerException("Socket is null");
+ }
+
+ if (!s.isConnected()) {
+ throw new IOException("Socket is not connected");
+ }
+
+ try {
+ initSSL();
+
+ EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
+ this.params, s.getPort(), s.getInetAddress());
+ EngineHelper.setUseClientMode(false);
+
+ /* register custom receive callback to read consumed first */
+ if (consumed != null) {
+ ConsumedRecvCallback recvCb = new ConsumedRecvCallback();
+ this.ssl.setIORecv(recvCb);
+ ConsumedRecvCtx recvCtx = new ConsumedRecvCtx(s, consumed);
+ this.ssl.setIOReadCtx(recvCtx);
+ this.ioCallbacksSet = true;
+ }
+
+ } catch (WolfSSLException | WolfSSLJNIException e) {
+ throw new IOException(e);
+ }
+ }
+
+ /**
+ * Create new internal WolfSSLSession object for use with this SSLSocket.
+ *
+ * @throws WolfSSLException on error creating WolfSSLSession
+ */
+ private void initSSL() throws WolfSSLException {
+
+ /* Initialize WolfSSLSession object, wraps WOLFSSL structure. */
+ ssl = new WolfSSLSession(ctx);
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "created new native WOLFSSL");
+ }
+
+ /**
+ * Initialize this WolfSSLSocket.
+ *
+ * Internal method, should be called before any handshake, I/O, or
+ * other operations are conducted that would rely on a set up key/cert,
+ * file descriptor, or I/O callback.
+ *
+ * This logic is not included directly in WolfSSLSocket constructors
+ * to avoid possible 'this' escape before subclass is fully initialized
+ * when using 'this' from setFd().
+ *
+ * @throws IOException if initialization fails
+ */
+ private void checkAndInitSSLSocket() throws IOException {
+
+ synchronized (initLock) {
+
+ if (isInitialized) {
+ return;
+ }
+
+ try {
+ /* Load private key and cert chain from WolfSSLAuthStore */
+ if (this.socket != null) {
+ EngineHelper.LoadKeyAndCertChain(this.socket, null);
+ } else {
+ EngineHelper.LoadKeyAndCertChain(this, null);
+ }
+
+ /* If underlying Socket connected, set fd */
+ if (isConnected()) {
+ setFd();
+ }
+
+ isInitialized = true;
+
+ } catch (WolfSSLException | CertificateEncodingException |
+ IOException e) {
+ throw new IOException(e);
+ }
+ }
+ }
+
+ /**
+ * Register I/O callbacks with native wolfSSL which use
+ * Input/OutputStream of the wrapped Socket object.
+ *
+ * Called by setFd() if ssl.setFd() fails to find or set the internal
+ * SocketImpl file descriptor.
+ *
+ * @throws WolfSSLException if this.socket is null or setting I/O
+ * callbacks or ctx fails
+ */
+ private void setIOCallbacks() throws WolfSSLException {
+
+ if (this.socket == null) {
+ throw new WolfSSLException(
+ "Internal Socket is null, unable to set I/O callbacks");
+ }
+
+ if (this.ioCallbacksSet) {
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "wolfSSL I/O callbacks already set, skipping");
+ return;
+ }
+
+ try {
+ /* Register send callback and context */
+ SocketSendCallback sendCb = new SocketSendCallback();
+ this.ssl.setIOSend(sendCb);
+ SocketSendCtx writeCtx = new SocketSendCtx(this.socket);
+ this.ssl.setIOWriteCtx(writeCtx);
+
+ /* Register recv callback and context */
+ SocketRecvCallback recvCb = new SocketRecvCallback();
+ this.ssl.setIORecv(recvCb);
+ SocketRecvCtx readCtx = new SocketRecvCtx(this.socket);
+ this.ssl.setIOReadCtx(readCtx);
+
+ } catch (WolfSSLJNIException e) {
+ throw new WolfSSLException(e);
+ }
+ }
+
+ private void setFd() throws IllegalArgumentException, WolfSSLException {
+
+ int ret;
+
+ if (ssl == null) {
+ throw new IllegalArgumentException("WolfSSLSession object is null");
+ }
+
+ /* Synchronized on ioLock to prevent read/write/connect/accept calls
+ * from possibly being called before descriptor or I/O callbacks
+ * have been set */
+ synchronized (ioLock) {
+ if (this.socket == null) {
+ ret = ssl.setFd(this);
+ if (ret != WolfSSL.SSL_SUCCESS) {
+ throw new WolfSSLException(
+ "Failed to set native Socket fd");
+ }
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "registered SSLSocket(this) with native wolfSSL");
+
+ } else {
+ ret = ssl.setFd(this.socket);
+ if (ret != WolfSSL.SSL_SUCCESS) {
+ /* Failed to find/set internal SocketImpl file descriptor.
+ * Try using I/O callbacks instead with
+ * Input/OutputStream */
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "Failed to set native SocketImpl fd, " +
+ "trying I/O callbacks");
+
+ setIOCallbacks();
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "registered underlying Socket with " +
+ "wolfSSL I/O callbacks");
+ }
+ else {
+ WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
+ "registered Socket(this.socket) with native wolfSSL");
+ }
+ }
+ }
+ }
+
+
/**
* Returns unique SocketChannel object assiciated with this socket.
*/
@@ -775,203 +1002,6 @@ public final void shutdownOutput() throws IOException {
"supported by wolfSSLSocket");
}
- /**
- * Create new WolfSSLSocket object layered over an existing Socket.
- *
- * @param context WolfSSLContext to use with this SSLSocket
- * @param authStore WolfSSLAuthStore to use with this SSLSocket
- * @param params WolfSSLParameters to use with this SSLSocket
- * @param clientMode true if this is a client socket, otherwise false
- * @param s existing connected Socket
- * @param autoClose automatically close wrapped Socket when finished
- *
- * @throws IOException if initialization fails
- */
- public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
- WolfSSLAuthStore authStore, WolfSSLParameters params,
- boolean clientMode, Socket s, boolean autoClose)
- throws IOException {
-
- super();
- this.ctx = context;
- this.authStore = authStore;
- this.params = params.copy();
- this.socket = s;
- this.autoClose = autoClose;
-
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "creating new WolfSSLSocket(clientMode: " +
- String.valueOf(clientMode) + ", Socket, autoClose: " +
- String.valueOf(autoClose) + ")");
-
- if (!s.isConnected()) {
- throw new IOException("Socket is not connected");
- }
-
- try {
- initSSL();
- setFd();
-
- /* get helper class for common methods */
- EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, s.getPort(), s.getInetAddress());
- EngineHelper.setUseClientMode(clientMode);
- EngineHelper.LoadKeyAndCertChain(s, null);
-
- } catch (WolfSSLException | CertificateEncodingException e) {
- throw new IOException(e);
- }
- }
-
- /**
- * Create new WolfSSLSocket object layered over an existing Socket,
- * only a server mode Socket. Use pre-consumed InputStream data
- * if provided.
- *
- * @param context WolfSSLContext to use with this SSLSocket
- * @param authStore WolfSSLAuthStore to use with this SSLSocket
- * @param params WolfSSLParameters to use with this SSLSocket
- * @param s existing connected Socket
- * @param consumed pre-consumed Socket data to use for this SSLSocket
- * @param autoClose automatically close wrapped Socket when finished
- *
- * @throws IOException if initialization fails
- */
- public WolfSSLSocket(com.wolfssl.WolfSSLContext context,
- WolfSSLAuthStore authStore, WolfSSLParameters params, Socket s,
- InputStream consumed, boolean autoClose) throws IOException {
-
- super();
- this.ctx = context;
- this.authStore = authStore;
- this.params = params.copy();
- this.socket = s;
- this.autoClose = autoClose;
-
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "creating new WolfSSLSocket(Socket, InputStream, autoClose: " +
- String.valueOf(autoClose) + ")");
-
- if (s == null ) {
- throw new NullPointerException("Socket is null");
- }
-
- if (!s.isConnected()) {
- throw new IOException("Socket is not connected");
- }
-
- try {
- initSSL();
- setFd();
-
- /* get helper class for common methods */
- EngineHelper = new WolfSSLEngineHelper(this.ssl, this.authStore,
- this.params, s.getPort(), s.getInetAddress());
- EngineHelper.setUseClientMode(false);
- EngineHelper.LoadKeyAndCertChain(s, null);
-
- /* register custom receive callback to read consumed first */
- if (consumed != null) {
- ConsumedRecvCallback recvCb = new ConsumedRecvCallback();
- this.ssl.setIORecv(recvCb);
- ConsumedRecvCtx recvCtx = new ConsumedRecvCtx(s, consumed);
- this.ssl.setIOReadCtx(recvCtx);
- }
-
- } catch (WolfSSLException | WolfSSLJNIException |
- CertificateEncodingException e) {
- throw new IOException(e);
- }
- }
-
- private void initSSL() throws WolfSSLException {
-
- /* initialize WolfSSLSession object, which wraps the native
- * WOLFSSL structure. */
- ssl = new WolfSSLSession(ctx);
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "created new native WOLFSSL");
- }
-
- /**
- * Register I/O callbacks with native wolfSSL which use
- * Input/OutputStream of the wrapped Socket object.
- *
- * Called by setFd() if ssl.setFd() fails to find or set the internal
- * SocketImpl file descriptor.
- *
- * @throws WolfSSLException if this.socket is null or setting I/O
- * callbacks or ctx fails
- */
- private void setIOCallbacks() throws WolfSSLException {
-
- if (this.socket == null) {
- throw new WolfSSLException(
- "Internal Socket is null, unable to set I/O callbacks");
- }
-
- try {
- /* Register send callback and context */
- SocketSendCallback sendCb = new SocketSendCallback();
- this.ssl.setIOSend(sendCb);
- SocketSendCtx writeCtx = new SocketSendCtx(this.socket);
- this.ssl.setIOWriteCtx(writeCtx);
-
- /* Register recv callback and context */
- SocketRecvCallback recvCb = new SocketRecvCallback();
- this.ssl.setIORecv(recvCb);
- SocketRecvCtx readCtx = new SocketRecvCtx(this.socket);
- this.ssl.setIOReadCtx(readCtx);
-
- } catch (WolfSSLJNIException e) {
- throw new WolfSSLException(e);
- }
- }
-
- private void setFd() throws IllegalArgumentException, WolfSSLException {
-
- int ret;
-
- if (ssl == null) {
- throw new IllegalArgumentException("WolfSSLSession object is null");
- }
-
- /* Synchronized on ioLock to prevent read/write/connect/accept calls
- * from possibly being called before descriptor or I/O callbacks
- * have been set */
- synchronized (ioLock) {
- if (this.socket == null) {
- ret = ssl.setFd(this);
- if (ret != WolfSSL.SSL_SUCCESS) {
- throw new WolfSSLException(
- "Failed to set native Socket fd");
- }
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "registered SSLSocket(this) with native wolfSSL");
-
- } else {
- ret = ssl.setFd(this.socket);
- if (ret != WolfSSL.SSL_SUCCESS) {
- /* Failed to find/set internal SocketImpl file descriptor.
- * Try using I/O callbacks instead with
- * Input/OutputStream */
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "Failed to set native SocketImpl fd, " +
- "trying I/O callbacks");
-
- setIOCallbacks();
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "registered underlying Socket with " +
- "wolfSSL I/O callbacks");
- }
- else {
- WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
- "registered Socket(this.socket) with native wolfSSL");
- }
- }
- }
- }
-
/**
* Returns the supported cipher suite list for this socket, and that
* have been compiled into native wolfSSL library.
@@ -1415,6 +1445,8 @@ public synchronized void startHandshake() throws IOException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered startHandshake(), trying to get handshakeLock");
+ checkAndInitSSLSocket();
+
synchronized (handshakeLock) {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"thread got handshakeLock (initHandshake)");
@@ -1680,6 +1712,8 @@ public synchronized InputStream getInputStream() throws IOException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered getInputStream()");
+ checkAndInitSSLSocket();
+
if (!this.isConnected()) {
throw new IOException("Socket is not connected");
}
@@ -1710,6 +1744,7 @@ public synchronized OutputStream getOutputStream() throws IOException {
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
"entered getOutputStream()");
+ checkAndInitSSLSocket();
if (!this.isConnected()) {
throw new IOException("Socket is not connected");
@@ -1851,6 +1886,9 @@ public synchronized void close() throws IOException {
try {
if (beforeObjectInit == false) {
+
+ checkAndInitSSLSocket();
+
/* Check if underlying Socket is still open before closing,
* in case application calls SSLSocket.close() multiple times */
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
@@ -2051,12 +2089,8 @@ public synchronized void connect(SocketAddress endpoint)
/* if user is calling after WolfSSLSession creation, register
socket fd with native wolfSSL */
- try {
- if (ssl != null) {
- setFd();
- }
- } catch (WolfSSLException e) {
- throw new IOException(e);
+ if (ssl != null) {
+ checkAndInitSSLSocket();
}
}
@@ -2105,12 +2139,8 @@ public synchronized void connect(SocketAddress endpoint, int timeout)
/* if user is calling after WolfSSLSession creation, register
socket fd with native wolfSSL */
- try {
- if (ssl != null) {
- setFd();
- }
- } catch (WolfSSLException e) {
- throw new IOException(e);
+ if (ssl != null) {
+ checkAndInitSSLSocket();
}
}
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLUtil.java b/src/java/com/wolfssl/provider/jsse/WolfSSLUtil.java
index cea09075..835ac9fd 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLUtil.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLUtil.java
@@ -64,7 +64,7 @@ protected static String[] sanitizeProtocols(String[] protocols) {
String disabledAlgos =
Security.getProperty("jdk.tls.disabledAlgorithms");
- List disabledList = null;
+ List> disabledList = null;
/* If system property not set, no filtering needed */
if (disabledAlgos == null || disabledAlgos.isEmpty()) {
@@ -119,7 +119,7 @@ protected static String[] sanitizeSuites(String[] suites) {
String enabledSuites =
Security.getProperty("wolfjsse.enabledCipherSuites");
- List enabledList = null;
+ List> enabledList = null;
/* If system property not set, no filtering needed */
if (enabledSuites == null || enabledSuites.isEmpty()) {
diff --git a/src/java/com/wolfssl/provider/jsse/WolfSSLX509.java b/src/java/com/wolfssl/provider/jsse/WolfSSLX509.java
index f423bceb..f4ae45d7 100644
--- a/src/java/com/wolfssl/provider/jsse/WolfSSLX509.java
+++ b/src/java/com/wolfssl/provider/jsse/WolfSSLX509.java
@@ -57,8 +57,12 @@
*/
public class WolfSSLX509 extends X509Certificate {
+ /* X509Certificate class is serializable */
+ private static final long serialVersionUID = 1L;
+
/** Inner WolfSSLCertificate object */
private WolfSSLCertificate cert = null;
+
/** Certificate extension OID values */
private String[] extensionOid = {
"2.5.29.15", /* key usage */
@@ -521,7 +525,7 @@ public PublicKey getPublicKey() {
if (kf != null) {
spec = new X509EncodedKeySpec(der);
- key = (PublicKey)kf.generatePublic(spec);
+ key = kf.generatePublic(spec);
}
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
diff --git a/src/test/com/wolfssl/provider/jsse/test/WolfSSLContextTest.java b/src/test/com/wolfssl/provider/jsse/test/WolfSSLContextTest.java
index fcdf219a..70f785fc 100644
--- a/src/test/com/wolfssl/provider/jsse/test/WolfSSLContextTest.java
+++ b/src/test/com/wolfssl/provider/jsse/test/WolfSSLContextTest.java
@@ -412,7 +412,7 @@ private ArrayList buildExpectedDefaultProtocolList(
ArrayList expected = new ArrayList();
/* already sorted highest to lowest (ie TLSv1.3, ..., TLSv1.1) */
- List enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
+ List> enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
if (ctxProtocol == "TLS") {
if (enabledNativeProtocols.contains("TLSv1.3")) {
@@ -490,7 +490,7 @@ public void testJdkTlsDisabledAlgorithms() throws NoSuchProviderException,
System.out.print("\tjdk.tls.disabledAlgorithms");
- List enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
+ List> enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
if (enabledNativeProtocols == null) {
System.out.println("\t... failed");
fail("WolfSSL.getProtocols() returned null");
@@ -714,7 +714,7 @@ public void testWolfJSSEEnabledCipherSuites()
System.out.print("\twolfjsse.enabledCipherSuites");
- List enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
+ List> enabledNativeProtocols = Arrays.asList(WolfSSL.getProtocols());
if (enabledNativeProtocols == null) {
System.out.println("\t... failed");
fail("WolfSSL.getProtocols() returned null");
diff --git a/src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java b/src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java
index fd725845..8eada479 100644
--- a/src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java
+++ b/src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java
@@ -215,7 +215,11 @@ public void testCipherConnection()
ciphers = client.getSupportedCipherSuites();
certs = server.getSession().getLocalCertificates();
- if (certs != null) {
+ if (certs == null) {
+ error("\t... failed");
+ fail("no certs available from server SSLEngine.getSession()");
+ }
+ else {
certType = ((X509Certificate)certs[0]).getSigAlgName();
if (certType.contains("RSA")) {
/* use a ECDHE-RSA suite if available */
diff --git a/src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java b/src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java
index e825b935..d33eaf69 100644
--- a/src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java
+++ b/src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java
@@ -1054,7 +1054,7 @@ public void testPreConsumedSocket() throws Exception {
SSLSocket cs = (SSLSocket)ctx.getSocketFactory().createSocket();
cs.connect(new InetSocketAddress(serverSock.getLocalPort()));
- final Socket server = (Socket)serverSock.accept();
+ final Socket server = serverSock.accept();
ExecutorService es = Executors.newSingleThreadExecutor();
Future serverFuture = es.submit(new Callable() {
@@ -1390,8 +1390,8 @@ public void testAddHandshakeCompletedListener() throws Exception {
/* create new CTX */
this.ctx = tf.createSSLContext("TLS", ctxProvider);
- this.clientFlag = false;
- this.serverFlag = false;
+ clientFlag = false;
+ serverFlag = false;
/* create SSLServerSocket first to get ephemeral port */
SSLServerSocket ss = (SSLServerSocket)ctx.getServerSocketFactory()
@@ -2376,7 +2376,7 @@ public void testSocketConnectException() throws Exception {
try {
/* connect to invalid host/port, expect java.net.ConnectException.
- * we do not expecdt anything to be running at localhost:12345 */
+ * we do not expect anything to be running at localhost:12345 */
SSLSocket cs = (SSLSocket)sf.createSocket("localhost", 12345);
} catch (ConnectException ce) {
/* expected */
@@ -2398,11 +2398,13 @@ public void testClientServerUsingSystemProperties() throws Exception {
System.setProperty("javax.net.ssl.trustStore", tf.clientJKS);
System.setProperty("javax.net.ssl.trustStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
SSLContext ctx = SSLContext.getInstance("TLS", ctxProvider);
@@ -2456,7 +2458,8 @@ public Void call() throws Exception {
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
ctx = SSLContext.getInstance("TLS", ctxProvider);
@@ -2475,11 +2478,13 @@ public Void call() throws Exception {
/* ------------------------------------------------ */
System.setProperty("javax.net.ssl.trustStore", "badstorepath");
System.setProperty("javax.net.ssl.trustStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
ctx = SSLContext.getInstance("TLS", ctxProvider);
@@ -2498,11 +2503,13 @@ public Void call() throws Exception {
/* ------------------------------------------------ */
System.setProperty("javax.net.ssl.trustStore", tf.clientJKS);
System.setProperty("javax.net.ssl.trustStoreType", "badtype");
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
ctx = SSLContext.getInstance("TLS", ctxProvider);
@@ -2521,7 +2528,8 @@ public Void call() throws Exception {
/* ------------------------------------------------ */
System.setProperty("javax.net.ssl.trustStore", tf.clientJKS);
System.setProperty("javax.net.ssl.trustStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
@@ -2544,11 +2552,13 @@ public Void call() throws Exception {
/* ------------------------------------------------ */
System.setProperty("javax.net.ssl.trustStore", tf.clientJKS);
System.setProperty("javax.net.ssl.trustStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", "badpath");
System.setProperty("javax.net.ssl.keyStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
ctx = SSLContext.getInstance("TLS", ctxProvider);
@@ -2567,11 +2577,13 @@ public Void call() throws Exception {
/* ------------------------------------------------ */
System.setProperty("javax.net.ssl.trustStore", tf.clientJKS);
System.setProperty("javax.net.ssl.trustStoreType", tf.keyStoreType);
- System.setProperty("javax.net.ssl.trustStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ WolfSSLTestFactory.jksPassStr);
System.setProperty("javax.net.ssl.keyStore", tf.clientJKS);
System.setProperty("javax.net.ssl.keyStoreType", "badtype");
- System.setProperty("javax.net.ssl.keyStorePassword", tf.jksPassStr);
+ System.setProperty("javax.net.ssl.keyStorePassword",
+ WolfSSLTestFactory.jksPassStr);
ctx = SSLContext.getInstance("TLS", ctxProvider);
diff --git a/src/test/com/wolfssl/provider/jsse/test/WolfSSLTestFactory.java b/src/test/com/wolfssl/provider/jsse/test/WolfSSLTestFactory.java
index 8e0a559a..b66fd410 100644
--- a/src/test/com/wolfssl/provider/jsse/test/WolfSSLTestFactory.java
+++ b/src/test/com/wolfssl/provider/jsse/test/WolfSSLTestFactory.java
@@ -68,13 +68,13 @@ class WolfSSLTestFactory {
protected String clientRSAJKS;
protected String clientECCJKS;
protected String clientRSAPSSJKS;
- protected static String serverJKS;
+ protected String serverJKS;
protected String serverRSA1024JKS;
protected String serverRSAJKS;
protected String serverECCJKS;
protected String serverRSAPSSJKS;
protected String caJKS;
- protected static String caClientJKS;
+ protected String caClientJKS;
protected String caServerJKS;
protected String googleCACert;
@@ -858,7 +858,7 @@ protected boolean isAndroid() {
protected static boolean securityPropContains(String prop, String needle) {
String secProp = null;
- List propList = null;
+ List> propList = null;
if (prop == null || needle == null) {
return false;
diff --git a/src/test/com/wolfssl/provider/jsse/test/WolfSSLX509Test.java b/src/test/com/wolfssl/provider/jsse/test/WolfSSLX509Test.java
index 2d35153b..a55401b4 100644
--- a/src/test/com/wolfssl/provider/jsse/test/WolfSSLX509Test.java
+++ b/src/test/com/wolfssl/provider/jsse/test/WolfSSLX509Test.java
@@ -303,7 +303,7 @@ public void testPublicKey() {
store = KeyStore.getInstance(tf.keyStoreType);
stream = new FileInputStream(tf.allJKS);
- store.load(stream, tf.jksPass);
+ store.load(stream, WolfSSLTestFactory.jksPass);
stream.close();
ca = new WolfSSLX509(store.getCertificate("ca").getEncoded());
cax = new WolfSSLX509X(ca.getEncoded());
@@ -368,7 +368,7 @@ public void testVerifyProvider() {
store = KeyStore.getInstance(tf.keyStoreType);
stream = new FileInputStream(tf.allJKS);
- store.load(stream, tf.jksPass);
+ store.load(stream, WolfSSLTestFactory.jksPass);
stream.close();
server = new WolfSSLX509(store.getCertificate("server").getEncoded());
ca = new WolfSSLX509(store.getCertificate("ca").getEncoded());
diff --git a/src/test/com/wolfssl/test/WolfSSLCertificateTest.java b/src/test/com/wolfssl/test/WolfSSLCertificateTest.java
index 0a2856b5..732fea6a 100644
--- a/src/test/com/wolfssl/test/WolfSSLCertificateTest.java
+++ b/src/test/com/wolfssl/test/WolfSSLCertificateTest.java
@@ -574,9 +574,9 @@ public void test_getKeyUsage() {
boolean[] kuse;
if (WolfSSL.FileSystemEnabled() == true) {
- ext = new WolfSSLCertificate(this.external);
+ ext = new WolfSSLCertificate(external);
} else {
- ext = new WolfSSLCertificate(fileToByteArray(this.external),
+ ext = new WolfSSLCertificate(fileToByteArray(external),
WolfSSL.SSL_FILETYPE_ASN1);
}
diff --git a/src/test/com/wolfssl/test/WolfSSLContextTest.java b/src/test/com/wolfssl/test/WolfSSLContextTest.java
index ae92f35a..c228e73d 100644
--- a/src/test/com/wolfssl/test/WolfSSLContextTest.java
+++ b/src/test/com/wolfssl/test/WolfSSLContextTest.java
@@ -424,7 +424,7 @@ public void test_WolfSSLContext_setGroups() {
WolfSSL.WOLFSSL_ECC_SECP256R1
};
int[] tooLong = new int[50];
- int[] badGroups = { (int)0xDEAD, (int)0xBEEF };
+ int[] badGroups = { 0xDEAD, 0xBEEF };
System.out.print("\tsetGroups()");
try {
diff --git a/src/test/com/wolfssl/test/WolfSSLSessionTest.java b/src/test/com/wolfssl/test/WolfSSLSessionTest.java
index 403f63d0..b71e46d6 100644
--- a/src/test/com/wolfssl/test/WolfSSLSessionTest.java
+++ b/src/test/com/wolfssl/test/WolfSSLSessionTest.java
@@ -1102,14 +1102,14 @@ public Void call() throws Exception {
/* wolfSSL_SessionIsSetup() may not be available, don't treat
* NOT_COMPILED_IN as an error */
- ret = cliSes.sessionIsSetup(sessionPtr);
+ ret = WolfSSLSession.sessionIsSetup(sessionPtr);
if ((ret != 1) && (ret != WolfSSL.NOT_COMPILED_IN)) {
throw new Exception(
"WolfSSLSession.sessionIsSetup() did not return 1: " + ret);
}
/* Test duplicateSession(), wraps wolfSSL_SESSION_dup() */
- sesDup = cliSes.duplicateSession(sessionPtr);
+ sesDup = WolfSSLSession.duplicateSession(sessionPtr);
if (sesDup == 0) {
throw new Exception(
"WolfSSLSession.duplicateSession() returned 0");
@@ -1118,7 +1118,7 @@ public Void call() throws Exception {
throw new Exception(
"WolfSSLSession.duplicateSession() returned same pointer");
}
- cliSes.freeSession(sesDup);
+ WolfSSLSession.freeSession(sesDup);
sesDup = 0;
cliSes.shutdownSSL();
@@ -1160,7 +1160,7 @@ public Void call() throws Exception {
}
/* Get WOLFSSL_SESSION pointer, free original one first */
- cliSes.freeSession(sessionPtr);
+ WolfSSLSession.freeSession(sessionPtr);
sessionPtr = cliSes.getSession();
if (sessionPtr == 0) {
throw new Exception(
@@ -1168,7 +1168,7 @@ public Void call() throws Exception {
}
/* Free WOLFSSL_SESSION pointer */
- cliSes.freeSession(sessionPtr);
+ WolfSSLSession.freeSession(sessionPtr);
sessionPtr = 0;
/* Session should be marked as resumed */
@@ -1190,10 +1190,10 @@ public Void call() throws Exception {
} finally {
if (sessionPtr != 0) {
- cliSes.freeSession(sessionPtr);
+ WolfSSLSession.freeSession(sessionPtr);
}
if (sesDup != 0) {
- cliSes.freeSession(sesDup);
+ WolfSSLSession.freeSession(sesDup);
}
if (cliSes != null) {
cliSes.freeSSL();
diff --git a/src/test/com/wolfssl/test/WolfSSLTest.java b/src/test/com/wolfssl/test/WolfSSLTest.java
index 0efce832..36e309eb 100644
--- a/src/test/com/wolfssl/test/WolfSSLTest.java
+++ b/src/test/com/wolfssl/test/WolfSSLTest.java
@@ -85,22 +85,22 @@ public void test_WolfSSL_protocol() {
}
public void test_WolfSSL_Method_Allocators(WolfSSL lib) {
- tstMethod(lib.SSLv3_ServerMethod(), "SSLv3_ServerMethod()");
- tstMethod(lib.SSLv3_ClientMethod(), "SSLv3_ClientMethod()");
- tstMethod(lib.TLSv1_ServerMethod(), "TLSv1_ServerMethod()");
- tstMethod(lib.TLSv1_ClientMethod(), "TLSv1_ClientMethod()");
- tstMethod(lib.TLSv1_1_ServerMethod(), "TLSv1_1_ServerMethod()");
- tstMethod(lib.TLSv1_1_ClientMethod(), "TLSv1_1_ClientMethod()");
- tstMethod(lib.TLSv1_2_ServerMethod(), "TLSv1_2_ServerMethod()");
- tstMethod(lib.TLSv1_2_ClientMethod(), "TLSv1_2_ClientMethod()");
- tstMethod(lib.TLSv1_3_ServerMethod(), "TLSv1_3_ServerMethod()");
- tstMethod(lib.TLSv1_3_ClientMethod(), "TLSv1_3_ClientMethod()");
- tstMethod(lib.DTLSv1_ServerMethod(), "DTLSv1_ServerMethod()");
- tstMethod(lib.DTLSv1_ClientMethod(), "DTLSv1_ClientMethod()");
- tstMethod(lib.DTLSv1_2_ServerMethod(), "DTLSv1_2_ServerMethod()");
- tstMethod(lib.DTLSv1_2_ClientMethod(), "DTLSv1_2_ClientMethod()");
- tstMethod(lib.SSLv23_ServerMethod(), "SSLv23_ServerMethod()");
- tstMethod(lib.SSLv23_ClientMethod(), "SSLv23_ClientMethod()");
+ tstMethod(WolfSSL.SSLv3_ServerMethod(), "SSLv3_ServerMethod()");
+ tstMethod(WolfSSL.SSLv3_ClientMethod(), "SSLv3_ClientMethod()");
+ tstMethod(WolfSSL.TLSv1_ServerMethod(), "TLSv1_ServerMethod()");
+ tstMethod(WolfSSL.TLSv1_ClientMethod(), "TLSv1_ClientMethod()");
+ tstMethod(WolfSSL.TLSv1_1_ServerMethod(), "TLSv1_1_ServerMethod()");
+ tstMethod(WolfSSL.TLSv1_1_ClientMethod(), "TLSv1_1_ClientMethod()");
+ tstMethod(WolfSSL.TLSv1_2_ServerMethod(), "TLSv1_2_ServerMethod()");
+ tstMethod(WolfSSL.TLSv1_2_ClientMethod(), "TLSv1_2_ClientMethod()");
+ tstMethod(WolfSSL.TLSv1_3_ServerMethod(), "TLSv1_3_ServerMethod()");
+ tstMethod(WolfSSL.TLSv1_3_ClientMethod(), "TLSv1_3_ClientMethod()");
+ tstMethod(WolfSSL.DTLSv1_ServerMethod(), "DTLSv1_ServerMethod()");
+ tstMethod(WolfSSL.DTLSv1_ClientMethod(), "DTLSv1_ClientMethod()");
+ tstMethod(WolfSSL.DTLSv1_2_ServerMethod(), "DTLSv1_2_ServerMethod()");
+ tstMethod(WolfSSL.DTLSv1_2_ClientMethod(), "DTLSv1_2_ClientMethod()");
+ tstMethod(WolfSSL.SSLv23_ServerMethod(), "SSLv23_ServerMethod()");
+ tstMethod(WolfSSL.SSLv23_ClientMethod(), "SSLv23_ClientMethod()");
}
public void tstMethod(long method, String name) {