Fix Windows build warnings, update WindowsConfig.bat, ALPN bytes test in WolfSSLSession

pull/184/head
Chris Conlon 2024-04-05 12:17:52 -06:00
parent 56c4fe0573
commit 6229224d5d
5 changed files with 49 additions and 15 deletions

View File

@ -74,52 +74,52 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug FIPS|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release FIPS|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug FIPS|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release FIPS|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

View File

@ -9,7 +9,7 @@
:: included by other example .bat files.
:: wolfSSL Normal non-FIPS (DLL Debug x64)
SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\x64
SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\DLL Debug\x64
SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug\x64
:: wolfSSL Normal non-FIPS (DLL Release x64)

View File

@ -5476,7 +5476,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_useSupportedCurve
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setGroups
(JNIEnv* jenv, jobject jcl, jlong ctxPtr, jintArray groups)
{
#ifdef HAVE_SUPPORTED_CURVES
#if defined(HAVE_TLS13) && defined(HAVE_SUPPORTED_CURVES)
int ret = WOLFSSL_FAILURE;
int groupsSz = 0;
int* jniGroups = NULL;

View File

@ -4146,6 +4146,18 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_sslSetAlpnProtos
if (buff != NULL && buffSz > 0) {
ret = wolfSSL_set_alpn_protos(ssl, buff, buffSz);
#ifdef WOLFSSL_ERROR_CODE_OPENSSL
if (ret == 0) {
/* wolfSSL_set_alpn_protos() returns 0 on success if
* WOLFSSL_ERROR_CODE_OPENSSL is defined, to match behavior of
* OpenSSL for compatibility layer. We translate back to
* a consistent SSL_SUCCESS here */
ret = SSL_SUCCESS;
}
else {
ret = SSL_FAILURE;
}
#endif
}
(*jenv)->ReleaseByteArrayElements(jenv, alpnProtos,
@ -4279,7 +4291,7 @@ int NativeALPNSelectCb(WOLFSSL *ssl, const unsigned char **out,
jmethodID alpnSelectMethodId; /* internalAlpnSelectCallback ID */
int ret = 0;
int idx = 0;
unsigned int idx = 0;
int peerProtoCount = 0;
char* peerProtos = NULL;
char* peerProtosCopy = NULL;
@ -4533,7 +4545,7 @@ int NativeALPNSelectCb(WOLFSSL *ssl, const unsigned char **out,
/* get char* from jstring */
selectedProtoCharArr = (*jenv)->GetStringUTFChars(jenv,
selectedProto, 0);
selectedProtoCharArrSz = XSTRLEN(selectedProtoCharArr);
selectedProtoCharArrSz = (int)XSTRLEN(selectedProtoCharArr);
/* see if selected ALPN protocol is in original sent list */
if (selectedProtoCharArr != NULL) {

View File

@ -268,6 +268,7 @@ public class WolfSSLSessionTest {
if (!e.getMessage().equals("wolfSSL not compiled with PSK " +
"support")) {
System.out.println("\t\t... failed");
fail("Failed setPskClientCb test");
e.printStackTrace();
}
}
@ -303,6 +304,7 @@ public class WolfSSLSessionTest {
if (!e.getMessage().equals("wolfSSL not compiled with PSK " +
"support")) {
System.out.println("\t\t... failed");
fail("Failed setPskServerCb test");
e.printStackTrace();
}
}
@ -320,6 +322,7 @@ public class WolfSSLSessionTest {
}
} catch (IllegalStateException e) {
System.out.println("\t\t... failed");
fail("Failed usePskIdentityHint test");
e.printStackTrace();
}
System.out.println("\t\t... passed");
@ -335,6 +338,7 @@ public class WolfSSLSessionTest {
}
} catch (IllegalStateException e) {
System.out.println("\t\t... failed");
fail("Failed getPskIdentityHint test");
e.printStackTrace();
}
System.out.println("\t\t... passed");
@ -362,6 +366,7 @@ public class WolfSSLSessionTest {
String identity = ssl.getPskIdentity();
} catch (IllegalStateException e) {
System.out.println("\t\t... failed");
fail("Failed getPskIdentity test");
e.printStackTrace();
}
System.out.println("\t\t... passed");
@ -373,6 +378,7 @@ public class WolfSSLSessionTest {
ssl.setTimeout(5);
if (ssl.getTimeout() != 5) {
System.out.println("\t\t\t... failed");
fail("Failed timeout test");
}
System.out.println("\t\t\t... passed");
}
@ -382,6 +388,7 @@ public class WolfSSLSessionTest {
System.out.print("\tstatus()");
if (ssl.handshakeDone() == true) {
System.out.println("\t\t\t... failed");
fail("Failed status test");
}
System.out.println("\t\t\t... passed");
}
@ -397,6 +404,7 @@ public class WolfSSLSessionTest {
System.out.println("\t\t\t... skipped");
} else if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("\t\t\t... failed");
fail("Failed useSNI test");
} else {
System.out.println("\t\t\t... passed");
}
@ -408,7 +416,9 @@ public class WolfSSLSessionTest {
String[] alpnProtos = new String[] {
"h2", "http/1.1"
};
byte[] alpnProtoBytes = "http/1.1".getBytes();
String http11Alpn = "http/1.1";
byte[] alpnProtoBytes = http11Alpn.getBytes();
byte[] alpnProtoBytesPacked = new byte[1 + alpnProtoBytes.length];
System.out.print("\tuseALPN()");
@ -447,7 +457,12 @@ public class WolfSSLSessionTest {
/* Testing useALPN(byte[]) */
if (ret == WolfSSL.SSL_SUCCESS) {
ret = ssl.useALPN(alpnProtoBytes);
alpnProtoBytesPacked[0] = (byte)http11Alpn.length();
System.arraycopy(alpnProtoBytes, 0, alpnProtoBytesPacked, 1,
alpnProtoBytes.length);
ret = ssl.useALPN(alpnProtoBytesPacked);
}
if (ret == WolfSSL.SSL_SUCCESS) {
@ -462,6 +477,7 @@ public class WolfSSLSessionTest {
System.out.println("\t\t\t... skipped");
} else if (ret != WolfSSL.SSL_SUCCESS) {
System.out.println("\t\t\t... failed");
fail("Failed useALPN test");
} else {
System.out.println("\t\t\t... passed");
}
@ -475,6 +491,7 @@ public class WolfSSLSessionTest {
ssl.freeSSL();
} catch (WolfSSLJNIException e) {
System.out.println("\t\t\t... failed");
fail("Failed freeSSL test");
e.printStackTrace();
}
System.out.println("\t\t\t... passed");
@ -530,6 +547,7 @@ public class WolfSSLSessionTest {
} catch (Exception e) {
System.out.println("\t\t... failed");
fail("Failed UseAfterFree test");
e.printStackTrace();
return;
}
@ -542,6 +560,7 @@ public class WolfSSLSessionTest {
return;
} catch (SocketTimeoutException | SocketException e) {
System.out.println("\t\t... failed");
fail("Failed UseAfterFree test");
e.printStackTrace();
return;
}
@ -619,6 +638,7 @@ public class WolfSSLSessionTest {
} catch (Exception e) {
System.out.println("\t\t... failed");
fail("Failed getSessionID test");
e.printStackTrace();
return;
}
@ -649,6 +669,7 @@ public class WolfSSLSessionTest {
ret = ssl.useSecureRenegotiation();
if (ret != WolfSSL.SSL_SUCCESS && ret != WolfSSL.NOT_COMPILED_IN) {
System.out.println("... failed");
fail("Failed useSecureRenegotiation test");
ssl.freeSSL();
sslCtx.free();
return;
@ -659,6 +680,7 @@ public class WolfSSLSessionTest {
} catch (Exception e) {
System.out.println("... failed");
fail("Failed useSecureRenegotiation test");
e.printStackTrace();
return;
}