Skip to content

Commit 0c031ea

Browse files
author
Andras Fekete
committed
Client needs to have the same TLS version as server
1 parent aaa1227 commit 0c031ea

13 files changed

Lines changed: 50 additions & 3 deletions

tls/client-tls-bio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ int main(int argc, char** argv)
7979
}
8080

8181
/* Create and initialize WOLFSSL_CTX */
82+
#ifdef USE_TLSV13
83+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
84+
#else
8285
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
86+
#endif
8387
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
8488
ret = -1;
8589
goto exit;

tls/client-tls-cacb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ int Security(int sock)
132132
wolfSSL_Init(); /* initialize wolfSSL */
133133

134134
/* create and initialize WOLFSSL_CTX structure */
135+
#ifdef USE_TLSV13
136+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
137+
#else
135138
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
139+
#endif
136140
printf("SSL_CTX_new error.\n");
137141
ret = EXIT_FAILURE;
138142
goto exit;

tls/client-tls-callback.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ int main(int argc, char** argv)
179179

180180

181181
/* Create and initialize WOLFSSL_CTX */
182+
#ifdef USE_TLSV13
183+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
184+
#else
182185
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
186+
#endif
183187
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
184188
ret = -1;
185189
goto exit;

tls/client-tls-cryptocb.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,10 @@ int main(int argc, char** argv)
136136

137137
/* Create and initialize WOLFSSL_CTX */
138138
#ifdef USE_TLSV13
139-
ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method());
139+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
140140
#else
141-
ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
141+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
142142
#endif
143-
if (ctx == NULL) {
144143
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
145144
ret = -1;
146145
goto exit;

tls/client-tls-ecdhe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ int main(int argc, char** argv)
8383

8484

8585
/* Create and initialize WOLFSSL_CTX */
86+
#ifdef USE_TLSV13
87+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
88+
#else
8689
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
90+
#endif
8791
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
8892
ret = -1;
8993
goto exit;

tls/client-tls-nonblocking.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ int main(int argc, char** argv)
131131

132132

133133
/* Create and initialize WOLFSSL_CTX */
134+
#ifdef USE_TLSV13
135+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
136+
#else
134137
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
138+
#endif
135139
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
136140
ret = -1;
137141
goto exit;

tls/client-tls-pkcs12.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ int main(int argc, char** argv)
133133
wolfSSL_Init();
134134

135135
/* Create and initialize WOLFSSL_CTX */
136+
#ifdef USE_TLSV13
137+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
138+
#else
136139
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
140+
#endif
137141
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
138142
return -1;
139143
}

tls/client-tls.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ int main(int argc, char** argv)
100100
}
101101

102102
/* Create and initialize WOLFSSL_CTX */
103+
#ifdef USE_TLSV13
104+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_client_method())) == NULL) {
105+
#else
103106
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
107+
#endif
104108
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
105109
ret = -1;
106110
goto socket_cleanup;

tls/server-tls-callback.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ int main()
177177

178178

179179
/* Create and initialize WOLFSSL_CTX */
180+
#ifdef USE_TLSV13
181+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_server_method())) == NULL) {
182+
#else
180183
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method())) == NULL) {
184+
#endif
181185
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
182186
ret = -1;
183187
goto exit;

tls/server-tls-ecdhe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ int main()
7979

8080

8181
/* Create and initialize WOLFSSL_CTX */
82+
#ifdef USE_TLSV13
83+
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_3_server_method())) == NULL) {
84+
#else
8285
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method())) == NULL) {
86+
#endif
8387
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
8488
ret = -1;
8589
goto exit;

0 commit comments

Comments
 (0)