Skip to content

Commit ed2549c

Browse files
committed
Support building TLS examples with --disable-oldnames.
1 parent 005e08d commit ed2549c

13 files changed

Lines changed: 59 additions & 59 deletions

tls/client-tls-cacb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void CaCb(unsigned char* der, int sz, int type)
9797
}
9898

9999
ret = wolfSSL_X509_get_serial_number(x509, serial, &sz);
100-
if (ret == SSL_SUCCESS) {
100+
if (ret == WOLFSSL_SUCCESS) {
101101
int i;
102102
int strLen;
103103
char serialMsg[80];
@@ -134,28 +134,28 @@ int Security(int sock)
134134
/* create and initialize WOLFSSL_CTX structure */
135135
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
136136
printf("SSL_CTX_new error.\n");
137-
ret = EXIT_FAILURE;
137+
ret = EXIT_FAILURE;
138138
goto exit;
139139
}
140140

141141
/* set callback for action when CA's are added */
142142
wolfSSL_CTX_SetCACb(ctx, CaCb);
143143

144144
/* load CA certificates into wolfSSL_CTX. which will verify the server */
145-
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, cert, 0))
145+
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, cert, 0))
146146
!= WOLFSSL_SUCCESS) {
147147
printf("Error loading %s. Please check the file.\n", cert);
148148
goto exit;
149149
}
150150
if ((ssl = wolfSSL_new(ctx)) == NULL) {
151151
printf("wolfSSL_new error.\n");
152-
ret = EXIT_FAILURE;
152+
ret = EXIT_FAILURE;
153153
goto exit;
154154
}
155155
wolfSSL_set_fd(ssl, sock);
156156

157157
ret = wolfSSL_connect(ssl);
158-
if (ret == SSL_SUCCESS) {
158+
if (ret == WOLFSSL_SUCCESS) {
159159
ret = ClientGreet(sock, ssl);
160160
}
161161

@@ -190,7 +190,7 @@ int main(int argc, char** argv)
190190

191191
if (sockfd < 0) {
192192
printf("Failed to create socket. Error: %i\n", errno);
193-
ret = EXIT_FAILURE;
193+
ret = EXIT_FAILURE;
194194
goto exit;
195195
}
196196

tls/client-tls-cryptocb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ int main(int argc, char** argv)
541541

542542
/* Load client certificates into WOLFSSL_CTX */
543543
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, CA_FILE, NULL))
544-
!= SSL_SUCCESS) {
544+
!= WOLFSSL_SUCCESS) {
545545
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
546546
CA_FILE);
547547
goto exit;
@@ -561,7 +561,7 @@ int main(int argc, char** argv)
561561
}
562562

563563
/* Connect to wolfSSL on the server side */
564-
if ((ret = wolfSSL_connect(ssl)) != SSL_SUCCESS) {
564+
if ((ret = wolfSSL_connect(ssl)) != WOLFSSL_SUCCESS) {
565565
fprintf(stderr, "ERROR: failed to connect to wolfSSL\n");
566566
goto exit;
567567
}

tls/client-tls-ecdhe.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
int main(int argc, char** argv)
4848
{
49-
int ret;
49+
int ret;
5050
int sockfd = SOCKET_INVALID;
5151
struct sockaddr_in servAddr;
5252
char buff[256];
@@ -76,7 +76,7 @@ int main(int argc, char** argv)
7676
* 0 means choose the default protocol. */
7777
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
7878
fprintf(stderr, "ERROR: failed to create the socket\n");
79-
ret = -1;
79+
ret = -1;
8080
goto exit;
8181
}
8282

@@ -85,7 +85,7 @@ int main(int argc, char** argv)
8585
/* Create and initialize WOLFSSL_CTX */
8686
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
8787
fprintf(stderr, "ERROR: failed to create WOLFSSL_CTX\n");
88-
ret = -1;
88+
ret = -1;
8989
goto exit;
9090
}
9191

@@ -98,15 +98,15 @@ int main(int argc, char** argv)
9898
}
9999

100100
/* Load client ecc certificates into WOLFSSL_CTX */
101-
if ((ret = wolfSSL_CTX_use_certificate_chain_file(ctx, ECC_FILE)) !=
101+
if ((ret = wolfSSL_CTX_use_certificate_chain_file(ctx, ECC_FILE)) !=
102102
WOLFSSL_SUCCESS) {
103103
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
104104
ECC_FILE);
105105
goto exit;
106106
}
107107

108108
/* Load client ecc key into WOLFSSL_CTX */
109-
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM))
109+
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, WOLFSSL_FILETYPE_PEM))
110110
!= WOLFSSL_SUCCESS) {
111111
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
112112
KEY_FILE);
@@ -132,7 +132,7 @@ int main(int argc, char** argv)
132132
/* Get the server IPv4 address from the command line call */
133133
if (inet_pton(AF_INET, argv[1], &servAddr.sin_addr) != 1) {
134134
fprintf(stderr, "ERROR: invalid address\n");
135-
ret = -1;
135+
ret = -1;
136136
goto exit;
137137
}
138138

@@ -142,7 +142,7 @@ int main(int argc, char** argv)
142142
if (connect(sockfd, (struct sockaddr*) &servAddr, sizeof(servAddr))
143143
== -1) {
144144
fprintf(stderr, "ERROR: failed to connect\n");
145-
ret = -1;
145+
ret = -1;
146146
goto exit;
147147
}
148148

@@ -151,7 +151,7 @@ int main(int argc, char** argv)
151151
/* Create a WOLFSSL object */
152152
if ((ssl = wolfSSL_new(ctx)) == NULL) {
153153
fprintf(stderr, "ERROR: failed to create WOLFSSL object\n");
154-
ret = -1;
154+
ret = -1;
155155
goto exit;
156156
}
157157

@@ -171,7 +171,7 @@ int main(int argc, char** argv)
171171
memset(buff, 0, sizeof(buff));
172172
if (fgets(buff, sizeof(buff), stdin) == NULL) {
173173
fprintf(stderr, "ERROR: failed to get message for server\n");
174-
ret = -1;
174+
ret = -1;
175175
goto exit;
176176
}
177177
len = strnlen(buff, sizeof(buff));

tls/client-tls-uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int main(int argc, char** argv)
206206
wolfSSL_CTX_SetIORecv(ctx, uartIORx);
207207

208208
/* For testing disable peer cert verification */
209-
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
209+
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_NONE, NULL);
210210

211211
ssl = wolfSSL_new(ctx);
212212
if (ssl == NULL) {

tls/client-tls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int main(int argc, char** argv)
108108

109109
/* Load client certificates into WOLFSSL_CTX */
110110
if ((ret = wolfSSL_CTX_load_verify_locations(ctx, CERT_FILE, NULL))
111-
!= SSL_SUCCESS) {
111+
!= WOLFSSL_SUCCESS) {
112112
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
113113
CERT_FILE);
114114
goto ctx_cleanup;
@@ -128,7 +128,7 @@ int main(int argc, char** argv)
128128
}
129129

130130
/* Connect to wolfSSL on the server side */
131-
if ((ret = wolfSSL_connect(ssl)) != SSL_SUCCESS) {
131+
if ((ret = wolfSSL_connect(ssl)) != WOLFSSL_SUCCESS) {
132132
fprintf(stderr, "ERROR: failed to connect to wolfSSL\n");
133133
goto cleanup;
134134
}
@@ -161,7 +161,7 @@ int main(int argc, char** argv)
161161
printf("Server: %s\n", buff);
162162

163163
/* Bidirectional shutdown */
164-
while (wolfSSL_shutdown(ssl) == SSL_SHUTDOWN_NOT_DONE) {
164+
while (wolfSSL_shutdown(ssl) == WOLFSSL_SHUTDOWN_NOT_DONE) {
165165
printf("Shutdown not complete\n");
166166
}
167167

tls/memory-tls.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static void* client_thread(void* args)
147147
if (cli_ctx == NULL) err_sys("bad client ctx new");
148148

149149
int ret = wolfSSL_CTX_load_verify_locations(cli_ctx, cacert, NULL);
150-
if (ret != SSL_SUCCESS) err_sys("bad ca load");
150+
if (ret != WOLFSSL_SUCCESS) err_sys("bad ca load");
151151

152152
wolfSSL_SetIOSend(cli_ctx, ClientSend);
153153
wolfSSL_SetIORecv(cli_ctx, ClientRecv);
@@ -156,7 +156,7 @@ static void* client_thread(void* args)
156156
if (cli_ctx == NULL) err_sys("bad client new");
157157

158158
ret = wolfSSL_connect(cli_ssl);
159-
if (ret != SSL_SUCCESS) err_sys("bad client tls connect");
159+
if (ret != WOLFSSL_SUCCESS) err_sys("bad client tls connect");
160160
printf("wolfSSL client success!\n");
161161

162162
ret = wolfSSL_write(cli_ssl, "hello memory wolfSSL!", 21);
@@ -175,11 +175,11 @@ int main()
175175
WOLFSSL_CTX* srv_ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
176176
if (srv_ctx == NULL) err_sys("bad server ctx new");
177177

178-
int ret = wolfSSL_CTX_use_PrivateKey_file(srv_ctx, key, SSL_FILETYPE_PEM);
179-
if (ret != SSL_SUCCESS) err_sys("bad server key file load");
178+
int ret = wolfSSL_CTX_use_PrivateKey_file(srv_ctx, key, WOLFSSL_FILETYPE_PEM);
179+
if (ret != WOLFSSL_SUCCESS) err_sys("bad server key file load");
180180

181-
ret = wolfSSL_CTX_use_certificate_file(srv_ctx, cert, SSL_FILETYPE_PEM);
182-
if (ret != SSL_SUCCESS) err_sys("bad server cert file load");
181+
ret = wolfSSL_CTX_use_certificate_file(srv_ctx, cert, WOLFSSL_FILETYPE_PEM);
182+
if (ret != WOLFSSL_SUCCESS) err_sys("bad server cert file load");
183183

184184
wolfSSL_SetIOSend(srv_ctx, ServerSend);
185185
wolfSSL_SetIORecv(srv_ctx, ServerRecv);
@@ -193,7 +193,7 @@ int main()
193193

194194
/* accept tls connection without tcp sockets */
195195
ret = wolfSSL_accept(srv_ssl);
196-
if (ret != SSL_SUCCESS) err_sys("bad server tls accept");
196+
if (ret != WOLFSSL_SUCCESS) err_sys("bad server tls accept");
197197
printf("wolfSSL accept success!\n");
198198

199199
/* read msg post handshake from client */

tls/server-tls-callback.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int main()
170170
* 0 means choose the default protocol. */
171171
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
172172
fprintf(stderr, "ERROR: failed to create the socket\n");
173-
ret = -1;
173+
ret = -1;
174174
goto exit;
175175
}
176176

@@ -184,15 +184,15 @@ int main()
184184
}
185185

186186
/* Load server certificates into WOLFSSL_CTX */
187-
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM))
187+
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, WOLFSSL_FILETYPE_PEM))
188188
!= WOLFSSL_SUCCESS) {
189189
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
190190
CERT_FILE);
191191
goto exit;
192192
}
193193

194194
/* Load server key into WOLFSSL_CTX */
195-
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM))
195+
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, WOLFSSL_FILETYPE_PEM))
196196
!= WOLFSSL_SUCCESS) {
197197
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
198198
KEY_FILE);
@@ -220,7 +220,7 @@ int main()
220220
/* Bind the server socket to our port */
221221
if (bind(sockfd, (struct sockaddr*)&servAddr, sizeof(servAddr)) == -1) {
222222
fprintf(stderr, "ERROR: failed to bind\n");
223-
ret = -1;
223+
ret = -1;
224224
goto exit;
225225
}
226226

@@ -248,7 +248,7 @@ int main()
248248
/* Create a WOLFSSL object */
249249
if ((ssl = wolfSSL_new(ctx)) == NULL) {
250250
fprintf(stderr, "ERROR: failed to create WOLFSSL object\n");
251-
ret = -1;
251+
ret = -1;
252252
goto exit;
253253
}
254254

@@ -308,7 +308,7 @@ int main()
308308
}
309309

310310
ret = 0;
311-
311+
312312
exit:
313313
/* Cleanup and return */
314314
if (ssl)

tls/server-tls-cryptocb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,15 @@ int main(int argc, char** argv)
490490
}
491491

492492
/* Load server certificates into WOLFSSL_CTX */
493-
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM))
493+
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, WOLFSSL_FILETYPE_PEM))
494494
!= WOLFSSL_SUCCESS) {
495495
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
496496
CERT_FILE);
497497
goto exit;
498498
}
499499

500500
/* Load server key into WOLFSSL_CTX */
501-
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM))
501+
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, WOLFSSL_FILETYPE_PEM))
502502
!= WOLFSSL_SUCCESS) {
503503
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
504504
KEY_FILE);

tls/server-tls-ecdhe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ int main()
8686
}
8787

8888
/* Load server certificates into WOLFSSL_CTX */
89-
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM))
89+
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, WOLFSSL_FILETYPE_PEM))
9090
!= WOLFSSL_SUCCESS) {
9191
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
9292
CERT_FILE);
9393
goto exit;
9494
}
9595

9696
/* Load server key into WOLFSSL_CTX */
97-
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM))
97+
if ((ret = wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, WOLFSSL_FILETYPE_PEM))
9898
!= WOLFSSL_SUCCESS) {
9999
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
100100
KEY_FILE);

tls/server-tls-nonblocking.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int main()
125125
if (fcntl(sockfd, F_SETFL, O_NONBLOCK) == -1) {
126126
fprintf(stderr, "ERROR: failed to set socket options\n");
127127
ret = -1;
128-
goto exit;
128+
goto exit;
129129
}
130130

131131

@@ -138,20 +138,20 @@ int main()
138138
}
139139

140140
/* Load server certificates into WOLFSSL_CTX */
141-
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, SSL_FILETYPE_PEM))
141+
if ((ret = wolfSSL_CTX_use_certificate_file(ctx, CERT_FILE, WOLFSSL_FILETYPE_PEM))
142142
!= WOLFSSL_SUCCESS) {
143143
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
144144
CERT_FILE);
145145
goto exit;
146146
}
147147

148148
/* Load server key into WOLFSSL_CTX */
149-
if (wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, SSL_FILETYPE_PEM)
149+
if (wolfSSL_CTX_use_PrivateKey_file(ctx, KEY_FILE, WOLFSSL_FILETYPE_PEM)
150150
!= WOLFSSL_SUCCESS) {
151151
fprintf(stderr, "ERROR: failed to load %s, please check the file.\n",
152152
KEY_FILE);
153153
ret = -1;
154-
goto exit;
154+
goto exit;
155155
}
156156

157157

@@ -191,7 +191,7 @@ int main()
191191
/* non-blocking, wait for read activity on socket */
192192
tcp_select(sockfd, SELECT_WAIT_SEC, 1);
193193
continue;
194-
}
194+
}
195195
else if (errno == EINPROGRESS || errno == EALREADY) {
196196
break;
197197
}
@@ -212,10 +212,10 @@ int main()
212212
fprintf(stderr, "ERROR: Failed to set the file descriptor\n");
213213
goto exit;
214214
}
215-
215+
216216
/* Establish TLS connection */
217217
printf("wolfSSL_accepting\n");
218-
218+
219219
do {
220220
ret = wolfSSL_accept(ssl);
221221
err = wolfSSL_get_error(ssl, ret);
@@ -234,7 +234,7 @@ int main()
234234
do {
235235
ret = wolfSSL_read(ssl, buff, sizeof(buff)-1);
236236
err = wolfSSL_get_error(ssl, ret);
237-
237+
238238
if (err == WOLFSSL_ERROR_WANT_READ)
239239
tcp_select(sockfd, SELECT_WAIT_SEC, 1);
240240
}
@@ -302,6 +302,6 @@ int main()
302302
if (ctx)
303303
wolfSSL_CTX_free(ctx); /* Free the wolfSSL context object */
304304
wolfSSL_Cleanup(); /* Cleanup the wolfSSL environment */
305-
305+
306306
return ret;
307307
}

0 commit comments

Comments
 (0)