Skip to content

Commit b682c2c

Browse files
authored
Merge pull request #6437 from julek-wolfssl/windows-crl-monitor
Implement CRL monitor for Windows
2 parents 6028dfd + 7af1f0c commit b682c2c

22 files changed

Lines changed: 902 additions & 204 deletions

File tree

IDE/WIN/user_settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#define WC_RSA_BLINDING
3838
#define NO_MULTIBYTE_PRINT
3939

40+
#define HAVE_CRL
41+
#define HAVE_CRL_MONITOR
42+
4043
#if defined(WOLFSSL_LIB)
4144
/* The lib */
4245
#define OPENSSL_EXTRA

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8816,7 +8816,7 @@ rm cyassl/options.h.bak
88168816
if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_LINUXKM" = "no"
88178817
then
88188818
SAVE_CFLAGS=$CFLAGS
8819-
CFLAGS="$CFLAGS -I. -I$srcdir"
8819+
CFLAGS="$CFLAGS $DEFS -I. -I$srcdir"
88208820
if test "$ENABLED_INTEL_QA" = "yes"
88218821
then
88228822
CFLAGS="$CFLAGS $QAT_FLAGS"

examples/client/client.c

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ static int lng_index = 0;
138138

139139
#endif
140140

141+
static int quieter = 0; /* Print fewer messages. This is helpful with overly
142+
* ambitious log parsers. */
143+
144+
#define LOG_ERROR(...) \
145+
do { \
146+
if (!quieter) \
147+
fprintf(stderr, __VA_ARGS__); \
148+
} while(0)
149+
141150
#ifdef HAVE_SESSION_TICKET
142151

143152
#ifndef SESSION_TICKET_LEN
@@ -435,7 +444,7 @@ static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
435444
}
436445
} while (err == WC_PENDING_E);
437446
if (ret != msgSz) {
438-
fprintf(stderr, "SSL_write_early_data msg error %d, %s\n", err,
447+
LOG_ERROR("SSL_write_early_data msg error %d, %s\n", err,
439448
wolfSSL_ERR_error_string(err, buffer));
440449
wolfSSL_free(ssl); ssl = NULL;
441450
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -455,7 +464,7 @@ static void EarlyData(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* msg,
455464
}
456465
} while (err == WC_PENDING_E);
457466
if (ret != msgSz) {
458-
fprintf(stderr, "SSL_write_early_data msg error %d, %s\n", err,
467+
LOG_ERROR("SSL_write_early_data msg error %d, %s\n", err,
459468
wolfSSL_ERR_error_string(err, buffer));
460469
wolfSSL_free(ssl);
461470
wolfSSL_CTX_free(ctx);
@@ -723,7 +732,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
723732
}
724733
} while (err == WC_PENDING_E);
725734
if (ret != len) {
726-
fprintf(stderr, "SSL_write bench error %d!\n", err);
735+
LOG_ERROR("SSL_write bench error %d!\n", err);
727736
if (!exitWithRet)
728737
err_sys("SSL_write failed");
729738
goto doExit;
@@ -749,7 +758,7 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
749758
#endif
750759
if (err != WOLFSSL_ERROR_WANT_READ &&
751760
err != WOLFSSL_ERROR_WANT_WRITE) {
752-
fprintf(stderr, "SSL_read bench error %d\n", err);
761+
LOG_ERROR("SSL_read bench error %d\n", err);
753762
err_sys("SSL_read failed");
754763
}
755764
}
@@ -943,7 +952,7 @@ static int SMTP_Shutdown(WOLFSSL* ssl, int wc_shutdown)
943952
printf("Bidirectional shutdown complete\n");
944953
}
945954
if (ret != WOLFSSL_SUCCESS)
946-
fprintf(stderr, "Bidirectional shutdown failed\n");
955+
LOG_ERROR("Bidirectional shutdown failed\n");
947956
}
948957

949958
return WOLFSSL_SUCCESS;
@@ -974,7 +983,7 @@ static int ClientWrite(WOLFSSL* ssl, const char* msg, int msgSz, const char* str
974983
);
975984
if (ret != msgSz) {
976985
char buffer[WOLFSSL_MAX_ERROR_SZ];
977-
fprintf(stderr, "SSL_write%s msg error %d, %s\n", str, err,
986+
LOG_ERROR("SSL_write%s msg error %d, %s\n", str, err,
978987
wolfSSL_ERR_error_string(err, buffer));
979988
if (!exitWithRet) {
980989
err_sys("SSL_write failed");
@@ -1005,7 +1014,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
10051014
#endif
10061015
if (err != WOLFSSL_ERROR_WANT_READ &&
10071016
err != WOLFSSL_ERROR_WANT_WRITE && err != APP_DATA_READY) {
1008-
fprintf(stderr, "SSL_read reply error %d, %s\n", err,
1017+
LOG_ERROR("SSL_read reply error %d, %s\n", err,
10091018
wolfSSL_ERR_error_string(err, buffer));
10101019
if (!exitWithRet) {
10111020
err_sys("SSL_read failed");
@@ -1021,7 +1030,7 @@ static int ClientRead(WOLFSSL* ssl, char* reply, int replyLen, int mustRead,
10211030
|| err == WOLFSSL_ERROR_WANT_WRITE)) {
10221031
elapsed = current_time(0) - start;
10231032
if (elapsed > MAX_NON_BLOCK_SEC) {
1024-
fprintf(stderr, "Nonblocking read timeout\n");
1033+
LOG_ERROR("Nonblocking read timeout\n");
10251034
ret = WOLFSSL_FATAL_ERROR;
10261035
break;
10271036
}
@@ -1505,12 +1514,12 @@ static void showPeerPEM(WOLFSSL* ssl)
15051514
if (peer) {
15061515
WOLFSSL_BIO* bioOut = wolfSSL_BIO_new(wolfSSL_BIO_s_file());
15071516
if (bioOut == NULL) {
1508-
fprintf(stderr, "failed to get bio on stdout\n");
1517+
LOG_ERROR("failed to get bio on stdout\n");
15091518
}
15101519
else {
15111520
if (wolfSSL_BIO_set_fp(bioOut, stdout, BIO_NOCLOSE)
15121521
!= WOLFSSL_SUCCESS) {
1513-
fprintf(stderr, "failed to set stdout to bio output\n");
1522+
LOG_ERROR("failed to set stdout to bio output\n");
15141523
wolfSSL_BIO_free(bioOut);
15151524
bioOut = NULL;
15161525
}
@@ -1751,7 +1760,7 @@ static int client_srtp_test(WOLFSSL *ssl, func_args *args)
17511760
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
17521761
&srtp_secret_length);
17531762
if (ret != LENGTH_ONLY_E) {
1754-
fprintf(stderr, "DTLS SRTP: Error getting keying material length\n");
1763+
LOG_ERROR("DTLS SRTP: Error getting keying material length\n");
17551764
return ret;
17561765
}
17571766

@@ -1765,7 +1774,7 @@ static int client_srtp_test(WOLFSSL *ssl, func_args *args)
17651774
&srtp_secret_length);
17661775
if (ret != WOLFSSL_SUCCESS) {
17671776
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
1768-
fprintf(stderr, "DTLS SRTP: Error getting keying material\n");
1777+
LOG_ERROR("DTLS SRTP: Error getting keying material\n");
17691778
return ret;
17701779
}
17711780

@@ -1862,6 +1871,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
18621871
#ifndef NO_PSK
18631872
{ "openssl-psk", 0, 265 },
18641873
#endif
1874+
{ "quieter", 0, 266 },
18651875
{ 0, 0, 0 }
18661876
};
18671877
#endif
@@ -2597,7 +2607,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
25972607
nonBlocking = 1;
25982608
simulateWantWrite = 1;
25992609
#else
2600-
fprintf(stderr, "Ignoring -6 since async I/O support not "
2610+
LOG_ERROR("Ignoring -6 since async I/O support not "
26012611
"compiled in.\n");
26022612
#endif
26032613
break;
@@ -2696,6 +2706,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
26962706
opensslPsk = 1;
26972707
#endif
26982708
break;
2709+
case 266:
2710+
quieter = 1;
2711+
break;
26992712
default:
27002713
Usage();
27012714
XEXIT_T(MY_EX_USAGE);
@@ -2780,7 +2793,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
27802793
#endif
27812794

27822795
if (done) {
2783-
fprintf(stderr, "external test can't be run in this mode\n");
2796+
LOG_ERROR("external test can't be run in this mode\n");
27842797

27852798
((func_args*)args)->return_code = 0;
27862799
XEXIT_T(EXIT_SUCCESS);
@@ -2818,7 +2831,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
28182831

28192832
#ifndef HAVE_SESSION_TICKET
28202833
if ((version >= 4) && resumeSession) {
2821-
fprintf(stderr, "Can't do TLS 1.3 resumption; need session tickets!\n");
2834+
LOG_ERROR("Can't do TLS 1.3 resumption; need session tickets!\n");
28222835
}
28232836
#endif
28242837

@@ -2831,7 +2844,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
28312844
if (usePqc) {
28322845
if (version == CLIENT_DOWNGRADE_VERSION ||
28332846
version == EITHER_DOWNGRADE_VERSION)
2834-
fprintf(stderr,
2847+
LOG_ERROR(
28352848
"WARNING: If a TLS 1.3 connection is not negotiated, you "
28362849
"will not be using a post-quantum group.\n");
28372850
else if (version != 4 && version != -4)
@@ -2928,11 +2941,11 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
29282941
#ifdef DEBUG_WOLFSSL
29292942
/* print off helper buffer sizes for use with static memory
29302943
* printing to stderr in case of debug mode turned on */
2931-
fprintf(stderr, "static memory management size = %d\n",
2944+
LOG_ERROR("static memory management size = %d\n",
29322945
wolfSSL_MemoryPaddingSz());
2933-
fprintf(stderr, "calculated optimum general buffer size = %d\n",
2946+
LOG_ERROR("calculated optimum general buffer size = %d\n",
29342947
wolfSSL_StaticBufferSz(memory, sizeof(memory), 0));
2935-
fprintf(stderr, "calculated optimum IO buffer size = %d\n",
2948+
LOG_ERROR("calculated optimum IO buffer size = %d\n",
29362949
wolfSSL_StaticBufferSz(memoryIO, sizeof(memoryIO),
29372950
WOLFMEM_IO_POOL_FIXED));
29382951
#endif /* DEBUG_WOLFSSL */
@@ -3331,7 +3344,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
33313344
#ifdef WOLFSSL_ASYNC_CRYPT
33323345
ret = wolfAsync_DevOpen(&devId);
33333346
if (ret < 0) {
3334-
fprintf(stderr, "Async device open failed\nRunning without async\n");
3347+
LOG_ERROR("Async device open failed\nRunning without async\n");
33353348
}
33363349
wolfSSL_CTX_SetDevId(ctx, devId);
33373350
#endif /* WOLFSSL_ASYNC_CRYPT */
@@ -3469,7 +3482,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
34693482
#endif
34703483

34713484
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
3472-
fprintf(stderr, "Before creating SSL\n");
3485+
LOG_ERROR("Before creating SSL\n");
34733486
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
34743487
err_sys("ctx not using static memory");
34753488
if (wolfSSL_PrintStats(&mem_stats) != 1) /* function in test.h */
@@ -3560,7 +3573,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
35603573
#endif
35613574

35623575
#if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL)
3563-
fprintf(stderr, "After creating SSL\n");
3576+
LOG_ERROR("After creating SSL\n");
35643577
if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
35653578
err_sys("ctx not using static memory");
35663579
if (wolfSSL_PrintStats(&mem_stats) != 1) /* function in test.h */
@@ -3796,7 +3809,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
37963809
#endif
37973810
if (ret != WOLFSSL_SUCCESS) {
37983811
err = wolfSSL_get_error(ssl, 0);
3799-
fprintf(stderr, "wolfSSL_connect error %d, %s\n", err,
3812+
LOG_ERROR("wolfSSL_connect error %d, %s\n", err,
38003813
wolfSSL_ERR_error_string(err, buffer));
38013814

38023815
/* cleanup */
@@ -4052,7 +4065,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
40524065
}
40534066
if (ret != WOLFSSL_SUCCESS) {
40544067
err = wolfSSL_get_error(ssl, 0);
4055-
fprintf(stderr, "wolfSSL_Rehandshake error %d, %s\n", err,
4068+
LOG_ERROR("wolfSSL_Rehandshake error %d, %s\n", err,
40564069
wolfSSL_ERR_error_string(err, buffer));
40574070
wolfSSL_free(ssl); ssl = NULL;
40584071
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -4061,7 +4074,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
40614074
}
40624075
}
40634076
else {
4064-
fprintf(stderr, "not doing secure resumption with non-blocking");
4077+
LOG_ERROR("not doing secure resumption with non-blocking");
40654078
}
40664079
} else {
40674080
if (!resumeScr) {
@@ -4243,12 +4256,12 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42434256
break;
42444257
}
42454258
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
4246-
fprintf(stderr, "Bidirectional shutdown failed\n");
4259+
LOG_ERROR("Bidirectional shutdown failed\n");
42474260
break;
42484261
}
42494262
}
42504263
if (ret != WOLFSSL_SUCCESS)
4251-
fprintf(stderr, "Bidirectional shutdown failed\n");
4264+
LOG_ERROR("Bidirectional shutdown failed\n");
42524265
}
42534266
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
42544267
if (atomicUser)
@@ -4260,8 +4273,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
42604273
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
42614274
err_sys("static memory was not used with ssl");
42624275

4263-
fprintf(stderr, "\nprint off SSL memory stats\n");
4264-
fprintf(stderr, "*** This is memory state before wolfSSL_free is called\n");
4276+
LOG_ERROR("\nprint off SSL memory stats\n");
4277+
LOG_ERROR("*** This is memory state before wolfSSL_free is called\n");
42654278
wolfSSL_PrintStatsConn(&ssl_stats);
42664279
#endif
42674280

@@ -4384,7 +4397,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
43844397
ret = NonBlockingSSL_Connect(sslResume); /* will keep retrying on timeout */
43854398
#endif
43864399
if (ret != WOLFSSL_SUCCESS) {
4387-
fprintf(stderr, "wolfSSL_connect resume error %d, %s\n", err,
4400+
LOG_ERROR("wolfSSL_connect resume error %d, %s\n", err,
43884401
wolfSSL_ERR_error_string(err, buffer));
43894402
wolfSSL_free(sslResume); sslResume = NULL;
43904403
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -4397,7 +4410,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
43974410
if (wolfSSL_session_reused(sslResume))
43984411
printf("reused session id\n");
43994412
else
4400-
fprintf(stderr, "didn't reuse session id!!!\n");
4413+
LOG_ERROR("didn't reuse session id!!!\n");
44014414

44024415
#ifdef HAVE_ALPN
44034416
if (alpnList != NULL) {
@@ -4432,7 +4445,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
44324445
printf("Beginning secure renegotiation.\n");
44334446
if (wolfSSL_Rehandshake(sslResume) != WOLFSSL_SUCCESS) {
44344447
err = wolfSSL_get_error(sslResume, 0);
4435-
fprintf(stderr, "err = %d, %s\n", err,
4448+
LOG_ERROR("err = %d, %s\n", err,
44364449
wolfSSL_ERR_error_string(err, buffer));
44374450
wolfSSL_free(sslResume); sslResume = NULL;
44384451
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -4446,7 +4459,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
44464459
printf("Beginning secure resumption.\n");
44474460
if (wolfSSL_SecureResume(sslResume) != WOLFSSL_SUCCESS) {
44484461
err = wolfSSL_get_error(sslResume, 0);
4449-
fprintf(stderr, "err = %d, %s\n", err,
4462+
LOG_ERROR("err = %d, %s\n", err,
44504463
wolfSSL_ERR_error_string(err, buffer));
44514464
wolfSSL_free(sslResume); sslResume = NULL;
44524465
wolfSSL_CTX_free(ctx); ctx = NULL;
@@ -4483,8 +4496,8 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
44834496
if (wolfSSL_is_static_memory(sslResume, &ssl_stats) != 1)
44844497
err_sys("static memory was not used with ssl");
44854498

4486-
fprintf(stderr, "\nprint off SSLresume memory stats\n");
4487-
fprintf(stderr, "*** This is memory state before wolfSSL_free is called\n");
4499+
LOG_ERROR("\nprint off SSLresume memory stats\n");
4500+
LOG_ERROR("*** This is memory state before wolfSSL_free is called\n");
44884501
wolfSSL_PrintStatsConn(&ssl_stats);
44894502
#endif
44904503

@@ -4503,7 +4516,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
45034516
wolfsentry_ret =
45044517
wolfsentry_shutdown(WOLFSENTRY_CONTEXT_ARGS_OUT_EX4(&wolfsentry, NULL));
45054518
if (wolfsentry_ret < 0) {
4506-
fprintf(stderr,
4519+
LOG_ERROR(
45074520
"wolfsentry_shutdown() returned " WOLFSENTRY_ERROR_FMT "\n",
45084521
WOLFSENTRY_ERROR_FMT_ARGS(wolfsentry_ret));
45094522
}

0 commit comments

Comments
 (0)