blob: 654dbc9750152804cf82ec294127d3e0d23c470e [file] [log] [blame]
Paul Bakker896ac222011-05-20 12:33:05 +00001/*
Paul Bakkercb79ae0b2011-05-20 12:44:16 +00002 * SSL server demonstration program using fork() for handling multiple clients
Paul Bakker896ac222011-05-20 12:33:05 +00003 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00004 * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
Paul Bakker896ac222011-05-20 12:33:05 +00005 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00006 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker896ac222011-05-20 12:33:05 +00007 *
Paul Bakker896ac222011-05-20 12:33:05 +00008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020023#if !defined(POLARSSL_CONFIG_FILE)
Manuel Pégourié-Gonnardabd6e022013-09-20 13:30:43 +020024#include "polarssl/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020025#else
26#include POLARSSL_CONFIG_FILE
27#endif
Paul Bakker896ac222011-05-20 12:33:05 +000028
Rich Evansf90016a2015-01-19 14:26:37 +000029#if defined(POLARSSL_PLATFORM_C)
30#include "polarssl/platform.h"
31#else
Rich Evans18b78c72015-02-11 14:06:19 +000032#include <stdio.h>
Rich Evansf90016a2015-01-19 14:26:37 +000033#define polarssl_fprintf fprintf
Rich Evans18b78c72015-02-11 14:06:19 +000034#define polarssl_printf printf
Rich Evansf90016a2015-01-19 14:26:37 +000035#endif
36
Paul Bakkercce9d772011-11-18 14:26:47 +000037#if defined(_WIN32)
Paul Bakker896ac222011-05-20 12:33:05 +000038#include <windows.h>
39#endif
40
Manuel Pégourié-Gonnard013bffe2015-02-13 14:09:44 +000041#if defined(POLARSSL_BIGNUM_C) && defined(POLARSSL_CERTS_C) && \
42 defined(POLARSSL_ENTROPY_C) && defined(POLARSSL_SSL_TLS_C) && \
43 defined(POLARSSL_SSL_SRV_C) && defined(POLARSSL_NET_C) && \
44 defined(POLARSSL_RSA_C) && defined(POLARSSL_CTR_DRBG_C) && \
45 defined(POLARSSL_X509_CRT_PARSE_C) && defined(POLARSSL_TIMING_C) && \
Rich Evans18b78c72015-02-11 14:06:19 +000046 defined(POLARSSL_FS_IO)
Paul Bakker508ad5a2011-12-04 17:09:26 +000047#include "polarssl/entropy.h"
48#include "polarssl/ctr_drbg.h"
Paul Bakker896ac222011-05-20 12:33:05 +000049#include "polarssl/certs.h"
50#include "polarssl/x509.h"
51#include "polarssl/ssl.h"
52#include "polarssl/net.h"
53#include "polarssl/timing.h"
54
Rich Evans18b78c72015-02-11 14:06:19 +000055#include <string.h>
56#include <stdio.h>
57#include <signal.h>
58#endif
59
60#if !defined(_MSC_VER) || defined(EFIX64) || defined(EFI32)
61#include <unistd.h>
62#endif
63
Paul Bakker896ac222011-05-20 12:33:05 +000064#define HTTP_RESPONSE \
65 "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
Manuel Pégourié-Gonnard91699212015-01-22 16:26:39 +000066 "<h2>mbed TLS Test Server</h2>\r\n" \
Paul Bakker896ac222011-05-20 12:33:05 +000067 "<p>Successful connection using: %s</p>\r\n"
68
Paul Bakkerb892b132011-10-12 09:19:43 +000069#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_CERTS_C) || \
Paul Bakker508ad5a2011-12-04 17:09:26 +000070 !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_SSL_TLS_C) || \
Paul Bakkerb892b132011-10-12 09:19:43 +000071 !defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) || \
Paul Bakkered27a042013-04-18 22:46:23 +020072 !defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \
Manuel Pégourié-Gonnard013bffe2015-02-13 14:09:44 +000073 !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_TIMING_C) || \
Rich Evans18b78c72015-02-11 14:06:19 +000074 !defined(POLARSSL_FS_IO)
Paul Bakkercce9d772011-11-18 14:26:47 +000075int main( int argc, char *argv[] )
Paul Bakkerb892b132011-10-12 09:19:43 +000076{
Paul Bakkercce9d772011-11-18 14:26:47 +000077 ((void) argc);
78 ((void) argv);
79
Rich Evansf90016a2015-01-19 14:26:37 +000080 polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_ENTROPY_C "
Paul Bakkerb892b132011-10-12 09:19:43 +000081 "and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
Paul Bakker508ad5a2011-12-04 17:09:26 +000082 "POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
Paul Bakker36713e82013-09-17 13:25:29 +020083 "POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C and/or "
Paul Bakkerfa9b1002013-07-03 15:31:03 +020084 "POLARSSL_TIMING_C not defined.\n");
Paul Bakkerb892b132011-10-12 09:19:43 +000085 return( 0 );
86}
Paul Bakkercce9d772011-11-18 14:26:47 +000087#elif defined(_WIN32)
Rich Evans85b05ec2015-02-12 11:37:29 +000088int main( void )
Paul Bakkerb892b132011-10-12 09:19:43 +000089{
Rich Evansf90016a2015-01-19 14:26:37 +000090 polarssl_printf("_WIN32 defined. This application requires fork() and signals "
Paul Bakkerb892b132011-10-12 09:19:43 +000091 "to work correctly.\n");
92 return( 0 );
93}
94#else
Paul Bakker896ac222011-05-20 12:33:05 +000095
96#define DEBUG_LEVEL 0
97
Paul Bakker3c5ef712013-06-25 16:37:45 +020098static void my_debug( void *ctx, int level, const char *str )
Paul Bakker896ac222011-05-20 12:33:05 +000099{
100 if( level < DEBUG_LEVEL )
101 {
Rich Evansf90016a2015-01-19 14:26:37 +0000102 polarssl_fprintf( (FILE *) ctx, "%s", str );
Paul Bakker896ac222011-05-20 12:33:05 +0000103 fflush( (FILE *) ctx );
104 }
105}
106
Rich Evans85b05ec2015-02-12 11:37:29 +0000107int main( void )
Paul Bakker896ac222011-05-20 12:33:05 +0000108{
109 int ret, len, cnt = 0, pid;
110 int listen_fd;
Manuel Pégourié-Gonnard68821da2013-09-16 12:34:33 +0200111 int client_fd = -1;
Paul Bakker896ac222011-05-20 12:33:05 +0000112 unsigned char buf[1024];
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200113 const char *pers = "ssl_fork_server";
Paul Bakker896ac222011-05-20 12:33:05 +0000114
Paul Bakker508ad5a2011-12-04 17:09:26 +0000115 entropy_context entropy;
116 ctr_drbg_context ctr_drbg;
Paul Bakker896ac222011-05-20 12:33:05 +0000117 ssl_context ssl;
Paul Bakkerc559c7a2013-09-18 14:13:26 +0200118 x509_crt srvcert;
Manuel Pégourié-Gonnardac755232013-08-19 14:10:16 +0200119 pk_context pkey;
Paul Bakker896ac222011-05-20 12:33:05 +0000120
Paul Bakker0c226102014-04-17 16:02:36 +0200121 memset( &ssl, 0, sizeof(ssl_context) );
122
123 entropy_init( &entropy );
124 pk_init( &pkey );
125 x509_crt_init( &srvcert );
126
Paul Bakker896ac222011-05-20 12:33:05 +0000127 signal( SIGCHLD, SIG_IGN );
128
129 /*
Paul Bakker508ad5a2011-12-04 17:09:26 +0000130 * 0. Initial seeding of the RNG
131 */
Rich Evansf90016a2015-01-19 14:26:37 +0000132 polarssl_printf( "\n . Initial seeding of the random generator..." );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000133 fflush( stdout );
134
Paul Bakker508ad5a2011-12-04 17:09:26 +0000135 if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200136 (const unsigned char *) pers,
137 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000138 {
Rich Evansf90016a2015-01-19 14:26:37 +0000139 polarssl_printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000140 goto exit;
141 }
142
Rich Evansf90016a2015-01-19 14:26:37 +0000143 polarssl_printf( " ok\n" );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000144
145 /*
Paul Bakker896ac222011-05-20 12:33:05 +0000146 * 1. Load the certificates and private RSA key
147 */
Rich Evansf90016a2015-01-19 14:26:37 +0000148 polarssl_printf( " . Loading the server cert. and key..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000149 fflush( stdout );
150
Paul Bakker896ac222011-05-20 12:33:05 +0000151 /*
152 * This demonstration program uses embedded test certificates.
Paul Bakkerddf26b42013-09-18 13:46:23 +0200153 * Instead, you may want to use x509_crt_parse_file() to read the
154 * server and CA certificates, as well as pk_parse_keyfile().
Paul Bakker896ac222011-05-20 12:33:05 +0000155 */
Paul Bakkerddf26b42013-09-18 13:46:23 +0200156 ret = x509_crt_parse( &srvcert, (const unsigned char *) test_srv_crt,
157 strlen( test_srv_crt ) );
Paul Bakker896ac222011-05-20 12:33:05 +0000158 if( ret != 0 )
159 {
Rich Evansf90016a2015-01-19 14:26:37 +0000160 polarssl_printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000161 goto exit;
162 }
163
Manuel Pégourié-Gonnard641de712013-09-25 13:23:33 +0200164 ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
165 strlen( test_ca_list ) );
Paul Bakker896ac222011-05-20 12:33:05 +0000166 if( ret != 0 )
167 {
Rich Evansf90016a2015-01-19 14:26:37 +0000168 polarssl_printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000169 goto exit;
170 }
171
Paul Bakker1a7550a2013-09-15 13:01:22 +0200172 ret = pk_parse_key( &pkey, (const unsigned char *) test_srv_key,
Paul Bakker896ac222011-05-20 12:33:05 +0000173 strlen( test_srv_key ), NULL, 0 );
174 if( ret != 0 )
175 {
Rich Evansf90016a2015-01-19 14:26:37 +0000176 polarssl_printf( " failed\n ! pk_parse_key returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000177 goto exit;
178 }
179
Rich Evansf90016a2015-01-19 14:26:37 +0000180 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000181
182 /*
183 * 2. Setup the listening TCP socket
184 */
Rich Evansf90016a2015-01-19 14:26:37 +0000185 polarssl_printf( " . Bind on https://localhost:4433/ ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000186 fflush( stdout );
187
188 if( ( ret = net_bind( &listen_fd, NULL, 4433 ) ) != 0 )
189 {
Rich Evansf90016a2015-01-19 14:26:37 +0000190 polarssl_printf( " failed\n ! net_bind returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000191 goto exit;
192 }
193
Rich Evansf90016a2015-01-19 14:26:37 +0000194 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000195
196 while( 1 )
197 {
198 /*
199 * 3. Wait until a client connects
200 */
201 client_fd = -1;
202 memset( &ssl, 0, sizeof( ssl ) );
203
Rich Evansf90016a2015-01-19 14:26:37 +0000204 polarssl_printf( " . Waiting for a remote connection ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000205 fflush( stdout );
206
207 if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
208 {
Rich Evansf90016a2015-01-19 14:26:37 +0000209 polarssl_printf( " failed\n ! net_accept returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000210 goto exit;
211 }
212
Rich Evansf90016a2015-01-19 14:26:37 +0000213 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000214
215 /*
216 * 3.5. Forking server thread
217 */
218
219 pid = fork();
220
Rich Evansf90016a2015-01-19 14:26:37 +0000221 polarssl_printf( " . Forking to handle connection ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000222 fflush( stdout );
223
224 if( pid < 0 )
225 {
Rich Evansf90016a2015-01-19 14:26:37 +0000226 polarssl_printf(" failed\n ! fork returned %d\n\n", pid );
Paul Bakker896ac222011-05-20 12:33:05 +0000227 goto exit;
228 }
229
Rich Evansf90016a2015-01-19 14:26:37 +0000230 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000231
232 if( pid != 0 )
233 {
Paul Bakker508ad5a2011-12-04 17:09:26 +0000234 if( ( ret = ctr_drbg_reseed( &ctr_drbg,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200235 (const unsigned char *) "parent",
236 6 ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000237 {
Rich Evansf90016a2015-01-19 14:26:37 +0000238 polarssl_printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000239 goto exit;
240 }
241
Paul Bakker896ac222011-05-20 12:33:05 +0000242 close( client_fd );
243 continue;
244 }
245
246 close( listen_fd );
247
248 /*
249 * 4. Setup stuff
250 */
Rich Evansf90016a2015-01-19 14:26:37 +0000251 polarssl_printf( " . Setting up the SSL data...." );
Paul Bakker896ac222011-05-20 12:33:05 +0000252 fflush( stdout );
253
Paul Bakker508ad5a2011-12-04 17:09:26 +0000254 if( ( ret = ctr_drbg_reseed( &ctr_drbg,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200255 (const unsigned char *) "child",
256 5 ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000257 {
Rich Evansf90016a2015-01-19 14:26:37 +0000258 polarssl_printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000259 goto exit;
260 }
Paul Bakker0c226102014-04-17 16:02:36 +0200261
Paul Bakker896ac222011-05-20 12:33:05 +0000262 if( ( ret = ssl_init( &ssl ) ) != 0 )
263 {
Rich Evansf90016a2015-01-19 14:26:37 +0000264 polarssl_printf( " failed\n ! ssl_init returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000265 goto exit;
266 }
267
Rich Evansf90016a2015-01-19 14:26:37 +0000268 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000269
270 ssl_set_endpoint( &ssl, SSL_IS_SERVER );
271 ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
272
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +0100273 /* SSLv3 is deprecated, set minimum to TLS 1.0 */
274 ssl_set_min_version( &ssl, SSL_MAJOR_VERSION_3,
275 SSL_MINOR_VERSION_1 );
Manuel Pégourié-Gonnardfa065812015-01-12 14:05:33 +0100276 /* RC4 is deprecated, disable it */
277 ssl_set_arc4_support( &ssl, SSL_ARC4_DISABLED );
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +0100278
Paul Bakker508ad5a2011-12-04 17:09:26 +0000279 ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg );
Paul Bakker896ac222011-05-20 12:33:05 +0000280 ssl_set_dbg( &ssl, my_debug, stdout );
281 ssl_set_bio( &ssl, net_recv, &client_fd,
282 net_send, &client_fd );
Paul Bakker896ac222011-05-20 12:33:05 +0000283
Paul Bakker896ac222011-05-20 12:33:05 +0000284 ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL );
Manuel Pégourié-Gonnardc5fd3912014-07-08 14:05:52 +0200285 if( ( ret = ssl_set_own_cert( &ssl, &srvcert, &pkey ) ) != 0 )
286 {
Rich Evansf90016a2015-01-19 14:26:37 +0000287 polarssl_printf( " failed\n ! ssl_set_own_cert returned %d\n\n", ret );
Manuel Pégourié-Gonnardc5fd3912014-07-08 14:05:52 +0200288 goto exit;
289 }
Paul Bakker896ac222011-05-20 12:33:05 +0000290
291 /*
292 * 5. Handshake
293 */
Rich Evansf90016a2015-01-19 14:26:37 +0000294 polarssl_printf( " . Performing the SSL/TLS handshake..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000295 fflush( stdout );
296
297 while( ( ret = ssl_handshake( &ssl ) ) != 0 )
298 {
299 if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
300 {
Rich Evansf90016a2015-01-19 14:26:37 +0000301 polarssl_printf( " failed\n ! ssl_handshake returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000302 goto exit;
303 }
304 }
305
Rich Evansf90016a2015-01-19 14:26:37 +0000306 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000307
308 /*
309 * 6. Read the HTTP Request
310 */
Rich Evansf90016a2015-01-19 14:26:37 +0000311 polarssl_printf( " < Read from client:" );
Paul Bakker896ac222011-05-20 12:33:05 +0000312 fflush( stdout );
313
314 do
315 {
316 len = sizeof( buf ) - 1;
317 memset( buf, 0, sizeof( buf ) );
318 ret = ssl_read( &ssl, buf, len );
319
320 if( ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE )
321 continue;
322
323 if( ret <= 0 )
324 {
325 switch( ret )
326 {
327 case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
Rich Evansf90016a2015-01-19 14:26:37 +0000328 polarssl_printf( " connection was closed gracefully\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000329 break;
330
331 case POLARSSL_ERR_NET_CONN_RESET:
Rich Evansf90016a2015-01-19 14:26:37 +0000332 polarssl_printf( " connection was reset by peer\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000333 break;
334
335 default:
Rich Evansf90016a2015-01-19 14:26:37 +0000336 polarssl_printf( " ssl_read returned %d\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000337 break;
338 }
339
340 break;
341 }
342
343 len = ret;
Rich Evansf90016a2015-01-19 14:26:37 +0000344 polarssl_printf( " %d bytes read\n\n%s", len, (char *) buf );
Manuel Pégourié-Gonnard401caad2015-02-14 15:53:24 +0000345
346 if( ret > 0 )
347 break;
Paul Bakker896ac222011-05-20 12:33:05 +0000348 }
Manuel Pégourié-Gonnard401caad2015-02-14 15:53:24 +0000349 while( 1 );
Paul Bakker896ac222011-05-20 12:33:05 +0000350
351 /*
352 * 7. Write the 200 Response
353 */
Rich Evansf90016a2015-01-19 14:26:37 +0000354 polarssl_printf( " > Write to client:" );
Paul Bakker896ac222011-05-20 12:33:05 +0000355 fflush( stdout );
356
357 len = sprintf( (char *) buf, HTTP_RESPONSE,
358 ssl_get_ciphersuite( &ssl ) );
359
Paul Bakker030decd2014-04-17 16:03:23 +0200360 while( cnt++ < 100 )
Paul Bakker896ac222011-05-20 12:33:05 +0000361 {
362 while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
363 {
364 if( ret == POLARSSL_ERR_NET_CONN_RESET )
365 {
Rich Evansf90016a2015-01-19 14:26:37 +0000366 polarssl_printf( " failed\n ! peer closed the connection\n\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000367 goto exit;
368 }
369
370 if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
371 {
Rich Evansf90016a2015-01-19 14:26:37 +0000372 polarssl_printf( " failed\n ! ssl_write returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000373 goto exit;
374 }
375 }
376 len = ret;
Rich Evansf90016a2015-01-19 14:26:37 +0000377 polarssl_printf( " %d bytes written\n\n%s\n", len, (char *) buf );
Paul Bakker896ac222011-05-20 12:33:05 +0000378
379 m_sleep( 1000 );
380 }
381
382 ssl_close_notify( &ssl );
383 goto exit;
384 }
385
386exit:
387
Paul Bakker0c226102014-04-17 16:02:36 +0200388 if( client_fd != -1 )
389 net_close( client_fd );
390
Paul Bakker36713e82013-09-17 13:25:29 +0200391 x509_crt_free( &srvcert );
Manuel Pégourié-Gonnardac755232013-08-19 14:10:16 +0200392 pk_free( &pkey );
Paul Bakker896ac222011-05-20 12:33:05 +0000393 ssl_free( &ssl );
Paul Bakkera317a982014-06-18 16:44:11 +0200394 ctr_drbg_free( &ctr_drbg );
Paul Bakker1ffefac2013-09-28 15:23:03 +0200395 entropy_free( &entropy );
Paul Bakker896ac222011-05-20 12:33:05 +0000396
Paul Bakkercce9d772011-11-18 14:26:47 +0000397#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +0000398 polarssl_printf( " Press Enter to exit this program.\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000399 fflush( stdout ); getchar();
400#endif
401
402 return( ret );
403}
Paul Bakker508ad5a2011-12-04 17:09:26 +0000404#endif /* POLARSSL_BIGNUM_C && POLARSSL_CERTS_C && POLARSSL_ENTROPY_C &&
Paul Bakker5690efc2011-05-26 13:16:06 +0000405 POLARSSL_SSL_TLS_C && POLARSSL_SSL_SRV_C && POLARSSL_NET_C &&
Paul Bakker508ad5a2011-12-04 17:09:26 +0000406 POLARSSL_RSA_C && POLARSSL_CTR_DRBG_C */