Skip to content

Commit 6229224

Browse files
committed
Fix Windows build warnings, update WindowsConfig.bat, ALPN bytes test in WolfSSLSession
1 parent 56c4fe0 commit 6229224

5 files changed

Lines changed: 49 additions & 15 deletions

File tree

IDE/WIN/wolfssljni.vcxproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,52 +74,52 @@
7474
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="Configuration">
7575
<ConfigurationType>DynamicLibrary</ConfigurationType>
7676
<UseDebugLibraries>true</UseDebugLibraries>
77-
<PlatformToolset>v142</PlatformToolset>
77+
<PlatformToolset>v143</PlatformToolset>
7878
<CharacterSet>Unicode</CharacterSet>
7979
</PropertyGroup>
8080
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug FIPS|Win32'" Label="Configuration">
8181
<ConfigurationType>DynamicLibrary</ConfigurationType>
8282
<UseDebugLibraries>true</UseDebugLibraries>
83-
<PlatformToolset>v142</PlatformToolset>
83+
<PlatformToolset>v143</PlatformToolset>
8484
<CharacterSet>Unicode</CharacterSet>
8585
</PropertyGroup>
8686
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'" Label="Configuration">
8787
<ConfigurationType>DynamicLibrary</ConfigurationType>
8888
<UseDebugLibraries>false</UseDebugLibraries>
89-
<PlatformToolset>v142</PlatformToolset>
89+
<PlatformToolset>v143</PlatformToolset>
9090
<WholeProgramOptimization>true</WholeProgramOptimization>
9191
<CharacterSet>Unicode</CharacterSet>
9292
</PropertyGroup>
9393
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release FIPS|Win32'" Label="Configuration">
9494
<ConfigurationType>DynamicLibrary</ConfigurationType>
9595
<UseDebugLibraries>false</UseDebugLibraries>
96-
<PlatformToolset>v142</PlatformToolset>
96+
<PlatformToolset>v143</PlatformToolset>
9797
<WholeProgramOptimization>true</WholeProgramOptimization>
9898
<CharacterSet>Unicode</CharacterSet>
9999
</PropertyGroup>
100100
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'" Label="Configuration">
101101
<ConfigurationType>DynamicLibrary</ConfigurationType>
102102
<UseDebugLibraries>true</UseDebugLibraries>
103-
<PlatformToolset>v142</PlatformToolset>
103+
<PlatformToolset>v143</PlatformToolset>
104104
<CharacterSet>Unicode</CharacterSet>
105105
</PropertyGroup>
106106
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug FIPS|x64'" Label="Configuration">
107107
<ConfigurationType>DynamicLibrary</ConfigurationType>
108108
<UseDebugLibraries>true</UseDebugLibraries>
109-
<PlatformToolset>v142</PlatformToolset>
109+
<PlatformToolset>v143</PlatformToolset>
110110
<CharacterSet>Unicode</CharacterSet>
111111
</PropertyGroup>
112112
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'" Label="Configuration">
113113
<ConfigurationType>DynamicLibrary</ConfigurationType>
114114
<UseDebugLibraries>false</UseDebugLibraries>
115-
<PlatformToolset>v142</PlatformToolset>
115+
<PlatformToolset>v143</PlatformToolset>
116116
<WholeProgramOptimization>true</WholeProgramOptimization>
117117
<CharacterSet>Unicode</CharacterSet>
118118
</PropertyGroup>
119119
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release FIPS|x64'" Label="Configuration">
120120
<ConfigurationType>DynamicLibrary</ConfigurationType>
121121
<UseDebugLibraries>false</UseDebugLibraries>
122-
<PlatformToolset>v142</PlatformToolset>
122+
<PlatformToolset>v143</PlatformToolset>
123123
<WholeProgramOptimization>true</WholeProgramOptimization>
124124
<CharacterSet>Unicode</CharacterSet>
125125
</PropertyGroup>
@@ -432,4 +432,4 @@ ant</Command>
432432
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
433433
<ImportGroup Label="ExtensionTargets">
434434
</ImportGroup>
435-
</Project>
435+
</Project>

examples/WindowsConfig.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:: included by other example .bat files.
1010

1111
:: wolfSSL Normal non-FIPS (DLL Debug x64)
12-
SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\IDE\WIN10\DLL Debug\x64
12+
SET WOLFSSL_DLL_DIR=..\..\..\wolfssl\DLL Debug\x64
1313
SET WOLFSSLJNI_DLL_DIR=..\..\IDE\WIN\DLL Debug\x64
1414

1515
:: wolfSSL Normal non-FIPS (DLL Release x64)

native/com_wolfssl_WolfSSLContext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5476,7 +5476,7 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_useSupportedCurve
54765476
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLContext_setGroups
54775477
(JNIEnv* jenv, jobject jcl, jlong ctxPtr, jintArray groups)
54785478
{
5479-
#ifdef HAVE_SUPPORTED_CURVES
5479+
#if defined(HAVE_TLS13) && defined(HAVE_SUPPORTED_CURVES)
54805480
int ret = WOLFSSL_FAILURE;
54815481
int groupsSz = 0;
54825482
int* jniGroups = NULL;

native/com_wolfssl_WolfSSLSession.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,6 +4146,18 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLSession_sslSetAlpnProtos
41464146

41474147
if (buff != NULL && buffSz > 0) {
41484148
ret = wolfSSL_set_alpn_protos(ssl, buff, buffSz);
4149+
#ifdef WOLFSSL_ERROR_CODE_OPENSSL
4150+
if (ret == 0) {
4151+
/* wolfSSL_set_alpn_protos() returns 0 on success if
4152+
* WOLFSSL_ERROR_CODE_OPENSSL is defined, to match behavior of
4153+
* OpenSSL for compatibility layer. We translate back to
4154+
* a consistent SSL_SUCCESS here */
4155+
ret = SSL_SUCCESS;
4156+
}
4157+
else {
4158+
ret = SSL_FAILURE;
4159+
}
4160+
#endif
41494161
}
41504162

41514163
(*jenv)->ReleaseByteArrayElements(jenv, alpnProtos,
@@ -4279,7 +4291,7 @@ int NativeALPNSelectCb(WOLFSSL *ssl, const unsigned char **out,
42794291
jmethodID alpnSelectMethodId; /* internalAlpnSelectCallback ID */
42804292

42814293
int ret = 0;
4282-
int idx = 0;
4294+
unsigned int idx = 0;
42834295
int peerProtoCount = 0;
42844296
char* peerProtos = NULL;
42854297
char* peerProtosCopy = NULL;
@@ -4533,7 +4545,7 @@ int NativeALPNSelectCb(WOLFSSL *ssl, const unsigned char **out,
45334545
/* get char* from jstring */
45344546
selectedProtoCharArr = (*jenv)->GetStringUTFChars(jenv,
45354547
selectedProto, 0);
4536-
selectedProtoCharArrSz = XSTRLEN(selectedProtoCharArr);
4548+
selectedProtoCharArrSz = (int)XSTRLEN(selectedProtoCharArr);
45374549

45384550
/* see if selected ALPN protocol is in original sent list */
45394551
if (selectedProtoCharArr != NULL) {

src/test/com/wolfssl/test/WolfSSLSessionTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ public void test_WolfSSLSession_setPskClientCb() {
268268
if (!e.getMessage().equals("wolfSSL not compiled with PSK " +
269269
"support")) {
270270
System.out.println("\t\t... failed");
271+
fail("Failed setPskClientCb test");
271272
e.printStackTrace();
272273
}
273274
}
@@ -303,6 +304,7 @@ public void test_WolfSSLSession_setPskServerCb() {
303304
if (!e.getMessage().equals("wolfSSL not compiled with PSK " +
304305
"support")) {
305306
System.out.println("\t\t... failed");
307+
fail("Failed setPskServerCb test");
306308
e.printStackTrace();
307309
}
308310
}
@@ -320,6 +322,7 @@ public void test_WolfSSLSession_usePskIdentityHint() {
320322
}
321323
} catch (IllegalStateException e) {
322324
System.out.println("\t\t... failed");
325+
fail("Failed usePskIdentityHint test");
323326
e.printStackTrace();
324327
}
325328
System.out.println("\t\t... passed");
@@ -335,6 +338,7 @@ public void test_WolfSSLSession_getPskIdentityHint() {
335338
}
336339
} catch (IllegalStateException e) {
337340
System.out.println("\t\t... failed");
341+
fail("Failed getPskIdentityHint test");
338342
e.printStackTrace();
339343
}
340344
System.out.println("\t\t... passed");
@@ -362,6 +366,7 @@ public void test_WolfSSLSession_getPskIdentity() {
362366
String identity = ssl.getPskIdentity();
363367
} catch (IllegalStateException e) {
364368
System.out.println("\t\t... failed");
369+
fail("Failed getPskIdentity test");
365370
e.printStackTrace();
366371
}
367372
System.out.println("\t\t... passed");
@@ -373,6 +378,7 @@ public void test_WolfSSLSession_timeout() {
373378
ssl.setTimeout(5);
374379
if (ssl.getTimeout() != 5) {
375380
System.out.println("\t\t\t... failed");
381+
fail("Failed timeout test");
376382
}
377383
System.out.println("\t\t\t... passed");
378384
}
@@ -382,6 +388,7 @@ public void test_WolfSSLSession_status() {
382388
System.out.print("\tstatus()");
383389
if (ssl.handshakeDone() == true) {
384390
System.out.println("\t\t\t... failed");
391+
fail("Failed status test");
385392
}
386393
System.out.println("\t\t\t... passed");
387394
}
@@ -397,6 +404,7 @@ public void test_WolfSSLSession_useSNI() {
397404
System.out.println("\t\t\t... skipped");
398405
} else if (ret != WolfSSL.SSL_SUCCESS) {
399406
System.out.println("\t\t\t... failed");
407+
fail("Failed useSNI test");
400408
} else {
401409
System.out.println("\t\t\t... passed");
402410
}
@@ -408,7 +416,9 @@ public void test_WolfSSLSession_useALPN() {
408416
String[] alpnProtos = new String[] {
409417
"h2", "http/1.1"
410418
};
411-
byte[] alpnProtoBytes = "http/1.1".getBytes();
419+
String http11Alpn = "http/1.1";
420+
byte[] alpnProtoBytes = http11Alpn.getBytes();
421+
byte[] alpnProtoBytesPacked = new byte[1 + alpnProtoBytes.length];
412422

413423
System.out.print("\tuseALPN()");
414424

@@ -447,7 +457,12 @@ public void test_WolfSSLSession_useALPN() {
447457

448458
/* Testing useALPN(byte[]) */
449459
if (ret == WolfSSL.SSL_SUCCESS) {
450-
ret = ssl.useALPN(alpnProtoBytes);
460+
461+
alpnProtoBytesPacked[0] = (byte)http11Alpn.length();
462+
System.arraycopy(alpnProtoBytes, 0, alpnProtoBytesPacked, 1,
463+
alpnProtoBytes.length);
464+
465+
ret = ssl.useALPN(alpnProtoBytesPacked);
451466
}
452467

453468
if (ret == WolfSSL.SSL_SUCCESS) {
@@ -462,6 +477,7 @@ public void test_WolfSSLSession_useALPN() {
462477
System.out.println("\t\t\t... skipped");
463478
} else if (ret != WolfSSL.SSL_SUCCESS) {
464479
System.out.println("\t\t\t... failed");
480+
fail("Failed useALPN test");
465481
} else {
466482
System.out.println("\t\t\t... passed");
467483
}
@@ -475,6 +491,7 @@ public void test_WolfSSLSession_freeSSL() {
475491
ssl.freeSSL();
476492
} catch (WolfSSLJNIException e) {
477493
System.out.println("\t\t\t... failed");
494+
fail("Failed freeSSL test");
478495
e.printStackTrace();
479496
}
480497
System.out.println("\t\t\t... passed");
@@ -530,6 +547,7 @@ public void test_WolfSSLSession_UseAfterFree() {
530547

531548
} catch (Exception e) {
532549
System.out.println("\t\t... failed");
550+
fail("Failed UseAfterFree test");
533551
e.printStackTrace();
534552
return;
535553
}
@@ -542,6 +560,7 @@ public void test_WolfSSLSession_UseAfterFree() {
542560
return;
543561
} catch (SocketTimeoutException | SocketException e) {
544562
System.out.println("\t\t... failed");
563+
fail("Failed UseAfterFree test");
545564
e.printStackTrace();
546565
return;
547566
}
@@ -619,6 +638,7 @@ public void test_WolfSSLSession_getSessionID() {
619638

620639
} catch (Exception e) {
621640
System.out.println("\t\t... failed");
641+
fail("Failed getSessionID test");
622642
e.printStackTrace();
623643
return;
624644
}
@@ -649,6 +669,7 @@ public void test_WolfSSLSession_useSecureRenegotiation() {
649669
ret = ssl.useSecureRenegotiation();
650670
if (ret != WolfSSL.SSL_SUCCESS && ret != WolfSSL.NOT_COMPILED_IN) {
651671
System.out.println("... failed");
672+
fail("Failed useSecureRenegotiation test");
652673
ssl.freeSSL();
653674
sslCtx.free();
654675
return;
@@ -659,6 +680,7 @@ public void test_WolfSSLSession_useSecureRenegotiation() {
659680

660681
} catch (Exception e) {
661682
System.out.println("... failed");
683+
fail("Failed useSecureRenegotiation test");
662684
e.printStackTrace();
663685
return;
664686
}

0 commit comments

Comments
 (0)