blob: 575160f84d82e6dc8375865263e22c16eb2edf77 [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é-Gonnard860b5162015-01-28 17:12:07 +00006 * This file is part of mbed TLS (https://polarssl.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
Rich Evans18b78c72015-02-11 14:06:19 +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) &&\
46 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) || \
Rich Evans18b78c72015-02-11 14:06:19 +000073 !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_TIMING_C) ||\
74 !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)
88int main( int argc, char *argv[] )
Paul Bakkerb892b132011-10-12 09:19:43 +000089{
Paul Bakkercce9d772011-11-18 14:26:47 +000090 ((void) argc);
91 ((void) argv);
92
Rich Evansf90016a2015-01-19 14:26:37 +000093 polarssl_printf("_WIN32 defined. This application requires fork() and signals "
Paul Bakkerb892b132011-10-12 09:19:43 +000094 "to work correctly.\n");
95 return( 0 );
96}
97#else
Paul Bakker896ac222011-05-20 12:33:05 +000098
99#define DEBUG_LEVEL 0
100
Paul Bakker3c5ef712013-06-25 16:37:45 +0200101static void my_debug( void *ctx, int level, const char *str )
Paul Bakker896ac222011-05-20 12:33:05 +0000102{
103 if( level < DEBUG_LEVEL )
104 {
Rich Evansf90016a2015-01-19 14:26:37 +0000105 polarssl_fprintf( (FILE *) ctx, "%s", str );
Paul Bakker896ac222011-05-20 12:33:05 +0000106 fflush( (FILE *) ctx );
107 }
108}
109
Paul Bakkercce9d772011-11-18 14:26:47 +0000110int main( int argc, char *argv[] )
Paul Bakker896ac222011-05-20 12:33:05 +0000111{
112 int ret, len, cnt = 0, pid;
113 int listen_fd;
Manuel Pégourié-Gonnard68821da2013-09-16 12:34:33 +0200114 int client_fd = -1;
Paul Bakker896ac222011-05-20 12:33:05 +0000115 unsigned char buf[1024];
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200116 const char *pers = "ssl_fork_server";
Paul Bakker896ac222011-05-20 12:33:05 +0000117
Paul Bakker508ad5a2011-12-04 17:09:26 +0000118 entropy_context entropy;
119 ctr_drbg_context ctr_drbg;
Paul Bakker896ac222011-05-20 12:33:05 +0000120 ssl_context ssl;
Paul Bakkerc559c7a2013-09-18 14:13:26 +0200121 x509_crt srvcert;
Manuel Pégourié-Gonnardac755232013-08-19 14:10:16 +0200122 pk_context pkey;
Paul Bakker896ac222011-05-20 12:33:05 +0000123
Paul Bakkercce9d772011-11-18 14:26:47 +0000124 ((void) argc);
125 ((void) argv);
126
Paul Bakker0c226102014-04-17 16:02:36 +0200127 memset( &ssl, 0, sizeof(ssl_context) );
128
129 entropy_init( &entropy );
130 pk_init( &pkey );
131 x509_crt_init( &srvcert );
132
Paul Bakker896ac222011-05-20 12:33:05 +0000133 signal( SIGCHLD, SIG_IGN );
134
135 /*
Paul Bakker508ad5a2011-12-04 17:09:26 +0000136 * 0. Initial seeding of the RNG
137 */
Rich Evansf90016a2015-01-19 14:26:37 +0000138 polarssl_printf( "\n . Initial seeding of the random generator..." );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000139 fflush( stdout );
140
Paul Bakker508ad5a2011-12-04 17:09:26 +0000141 if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200142 (const unsigned char *) pers,
143 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000144 {
Rich Evansf90016a2015-01-19 14:26:37 +0000145 polarssl_printf( " failed\n ! ctr_drbg_init returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000146 goto exit;
147 }
148
Rich Evansf90016a2015-01-19 14:26:37 +0000149 polarssl_printf( " ok\n" );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000150
151 /*
Paul Bakker896ac222011-05-20 12:33:05 +0000152 * 1. Load the certificates and private RSA key
153 */
Rich Evansf90016a2015-01-19 14:26:37 +0000154 polarssl_printf( " . Loading the server cert. and key..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000155 fflush( stdout );
156
Paul Bakker896ac222011-05-20 12:33:05 +0000157 /*
158 * This demonstration program uses embedded test certificates.
Paul Bakkerddf26b42013-09-18 13:46:23 +0200159 * Instead, you may want to use x509_crt_parse_file() to read the
160 * server and CA certificates, as well as pk_parse_keyfile().
Paul Bakker896ac222011-05-20 12:33:05 +0000161 */
Paul Bakkerddf26b42013-09-18 13:46:23 +0200162 ret = x509_crt_parse( &srvcert, (const unsigned char *) test_srv_crt,
163 strlen( test_srv_crt ) );
Paul Bakker896ac222011-05-20 12:33:05 +0000164 if( ret != 0 )
165 {
Rich Evansf90016a2015-01-19 14:26:37 +0000166 polarssl_printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000167 goto exit;
168 }
169
Manuel Pégourié-Gonnard641de712013-09-25 13:23:33 +0200170 ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list,
171 strlen( test_ca_list ) );
Paul Bakker896ac222011-05-20 12:33:05 +0000172 if( ret != 0 )
173 {
Rich Evansf90016a2015-01-19 14:26:37 +0000174 polarssl_printf( " failed\n ! x509_crt_parse returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000175 goto exit;
176 }
177
Paul Bakker1a7550a2013-09-15 13:01:22 +0200178 ret = pk_parse_key( &pkey, (const unsigned char *) test_srv_key,
Paul Bakker896ac222011-05-20 12:33:05 +0000179 strlen( test_srv_key ), NULL, 0 );
180 if( ret != 0 )
181 {
Rich Evansf90016a2015-01-19 14:26:37 +0000182 polarssl_printf( " failed\n ! pk_parse_key returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000183 goto exit;
184 }
185
Rich Evansf90016a2015-01-19 14:26:37 +0000186 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000187
188 /*
189 * 2. Setup the listening TCP socket
190 */
Rich Evansf90016a2015-01-19 14:26:37 +0000191 polarssl_printf( " . Bind on https://localhost:4433/ ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000192 fflush( stdout );
193
194 if( ( ret = net_bind( &listen_fd, NULL, 4433 ) ) != 0 )
195 {
Rich Evansf90016a2015-01-19 14:26:37 +0000196 polarssl_printf( " failed\n ! net_bind returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000197 goto exit;
198 }
199
Rich Evansf90016a2015-01-19 14:26:37 +0000200 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000201
202 while( 1 )
203 {
204 /*
205 * 3. Wait until a client connects
206 */
207 client_fd = -1;
208 memset( &ssl, 0, sizeof( ssl ) );
209
Rich Evansf90016a2015-01-19 14:26:37 +0000210 polarssl_printf( " . Waiting for a remote connection ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000211 fflush( stdout );
212
213 if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
214 {
Rich Evansf90016a2015-01-19 14:26:37 +0000215 polarssl_printf( " failed\n ! net_accept returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000216 goto exit;
217 }
218
Rich Evansf90016a2015-01-19 14:26:37 +0000219 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000220
221 /*
222 * 3.5. Forking server thread
223 */
224
225 pid = fork();
226
Rich Evansf90016a2015-01-19 14:26:37 +0000227 polarssl_printf( " . Forking to handle connection ..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000228 fflush( stdout );
229
230 if( pid < 0 )
231 {
Rich Evansf90016a2015-01-19 14:26:37 +0000232 polarssl_printf(" failed\n ! fork returned %d\n\n", pid );
Paul Bakker896ac222011-05-20 12:33:05 +0000233 goto exit;
234 }
235
Rich Evansf90016a2015-01-19 14:26:37 +0000236 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000237
238 if( pid != 0 )
239 {
Paul Bakker508ad5a2011-12-04 17:09:26 +0000240 if( ( ret = ctr_drbg_reseed( &ctr_drbg,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200241 (const unsigned char *) "parent",
242 6 ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000243 {
Rich Evansf90016a2015-01-19 14:26:37 +0000244 polarssl_printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000245 goto exit;
246 }
247
Paul Bakker896ac222011-05-20 12:33:05 +0000248 close( client_fd );
249 continue;
250 }
251
252 close( listen_fd );
253
254 /*
255 * 4. Setup stuff
256 */
Rich Evansf90016a2015-01-19 14:26:37 +0000257 polarssl_printf( " . Setting up the SSL data...." );
Paul Bakker896ac222011-05-20 12:33:05 +0000258 fflush( stdout );
259
Paul Bakker508ad5a2011-12-04 17:09:26 +0000260 if( ( ret = ctr_drbg_reseed( &ctr_drbg,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200261 (const unsigned char *) "child",
262 5 ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000263 {
Rich Evansf90016a2015-01-19 14:26:37 +0000264 polarssl_printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000265 goto exit;
266 }
Paul Bakker0c226102014-04-17 16:02:36 +0200267
Paul Bakker896ac222011-05-20 12:33:05 +0000268 if( ( ret = ssl_init( &ssl ) ) != 0 )
269 {
Rich Evansf90016a2015-01-19 14:26:37 +0000270 polarssl_printf( " failed\n ! ssl_init returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000271 goto exit;
272 }
273
Rich Evansf90016a2015-01-19 14:26:37 +0000274 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000275
276 ssl_set_endpoint( &ssl, SSL_IS_SERVER );
277 ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
278
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +0100279 /* SSLv3 is deprecated, set minimum to TLS 1.0 */
280 ssl_set_min_version( &ssl, SSL_MAJOR_VERSION_3,
281 SSL_MINOR_VERSION_1 );
Manuel Pégourié-Gonnardfa065812015-01-12 14:05:33 +0100282 /* RC4 is deprecated, disable it */
283 ssl_set_arc4_support( &ssl, SSL_ARC4_DISABLED );
Manuel Pégourié-Gonnard448ea502015-01-12 11:40:14 +0100284
Paul Bakker508ad5a2011-12-04 17:09:26 +0000285 ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg );
Paul Bakker896ac222011-05-20 12:33:05 +0000286 ssl_set_dbg( &ssl, my_debug, stdout );
287 ssl_set_bio( &ssl, net_recv, &client_fd,
288 net_send, &client_fd );
Paul Bakker896ac222011-05-20 12:33:05 +0000289
Paul Bakker896ac222011-05-20 12:33:05 +0000290 ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL );
Manuel Pégourié-Gonnardc5fd3912014-07-08 14:05:52 +0200291 if( ( ret = ssl_set_own_cert( &ssl, &srvcert, &pkey ) ) != 0 )
292 {
Rich Evansf90016a2015-01-19 14:26:37 +0000293 polarssl_printf( " failed\n ! ssl_set_own_cert returned %d\n\n", ret );
Manuel Pégourié-Gonnardc5fd3912014-07-08 14:05:52 +0200294 goto exit;
295 }
Paul Bakker896ac222011-05-20 12:33:05 +0000296
297 /*
298 * 5. Handshake
299 */
Rich Evansf90016a2015-01-19 14:26:37 +0000300 polarssl_printf( " . Performing the SSL/TLS handshake..." );
Paul Bakker896ac222011-05-20 12:33:05 +0000301 fflush( stdout );
302
303 while( ( ret = ssl_handshake( &ssl ) ) != 0 )
304 {
305 if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
306 {
Rich Evansf90016a2015-01-19 14:26:37 +0000307 polarssl_printf( " failed\n ! ssl_handshake returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000308 goto exit;
309 }
310 }
311
Rich Evansf90016a2015-01-19 14:26:37 +0000312 polarssl_printf( " ok\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000313
314 /*
315 * 6. Read the HTTP Request
316 */
Rich Evansf90016a2015-01-19 14:26:37 +0000317 polarssl_printf( " < Read from client:" );
Paul Bakker896ac222011-05-20 12:33:05 +0000318 fflush( stdout );
319
320 do
321 {
322 len = sizeof( buf ) - 1;
323 memset( buf, 0, sizeof( buf ) );
324 ret = ssl_read( &ssl, buf, len );
325
326 if( ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE )
327 continue;
328
329 if( ret <= 0 )
330 {
331 switch( ret )
332 {
333 case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
Rich Evansf90016a2015-01-19 14:26:37 +0000334 polarssl_printf( " connection was closed gracefully\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000335 break;
336
337 case POLARSSL_ERR_NET_CONN_RESET:
Rich Evansf90016a2015-01-19 14:26:37 +0000338 polarssl_printf( " connection was reset by peer\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000339 break;
340
341 default:
Rich Evansf90016a2015-01-19 14:26:37 +0000342 polarssl_printf( " ssl_read returned %d\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000343 break;
344 }
345
346 break;
347 }
348
349 len = ret;
Rich Evansf90016a2015-01-19 14:26:37 +0000350 polarssl_printf( " %d bytes read\n\n%s", len, (char *) buf );
Paul Bakker896ac222011-05-20 12:33:05 +0000351 }
352 while( 0 );
353
354 /*
355 * 7. Write the 200 Response
356 */
Rich Evansf90016a2015-01-19 14:26:37 +0000357 polarssl_printf( " > Write to client:" );
Paul Bakker896ac222011-05-20 12:33:05 +0000358 fflush( stdout );
359
360 len = sprintf( (char *) buf, HTTP_RESPONSE,
361 ssl_get_ciphersuite( &ssl ) );
362
Paul Bakker030decd2014-04-17 16:03:23 +0200363 while( cnt++ < 100 )
Paul Bakker896ac222011-05-20 12:33:05 +0000364 {
365 while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
366 {
367 if( ret == POLARSSL_ERR_NET_CONN_RESET )
368 {
Rich Evansf90016a2015-01-19 14:26:37 +0000369 polarssl_printf( " failed\n ! peer closed the connection\n\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000370 goto exit;
371 }
372
373 if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
374 {
Rich Evansf90016a2015-01-19 14:26:37 +0000375 polarssl_printf( " failed\n ! ssl_write returned %d\n\n", ret );
Paul Bakker896ac222011-05-20 12:33:05 +0000376 goto exit;
377 }
378 }
379 len = ret;
Rich Evansf90016a2015-01-19 14:26:37 +0000380 polarssl_printf( " %d bytes written\n\n%s\n", len, (char *) buf );
Paul Bakker896ac222011-05-20 12:33:05 +0000381
382 m_sleep( 1000 );
383 }
384
385 ssl_close_notify( &ssl );
386 goto exit;
387 }
388
389exit:
390
Paul Bakker0c226102014-04-17 16:02:36 +0200391 if( client_fd != -1 )
392 net_close( client_fd );
393
Paul Bakker36713e82013-09-17 13:25:29 +0200394 x509_crt_free( &srvcert );
Manuel Pégourié-Gonnardac755232013-08-19 14:10:16 +0200395 pk_free( &pkey );
Paul Bakker896ac222011-05-20 12:33:05 +0000396 ssl_free( &ssl );
Paul Bakkera317a982014-06-18 16:44:11 +0200397 ctr_drbg_free( &ctr_drbg );
Paul Bakker1ffefac2013-09-28 15:23:03 +0200398 entropy_free( &entropy );
Paul Bakker896ac222011-05-20 12:33:05 +0000399
Paul Bakkercce9d772011-11-18 14:26:47 +0000400#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +0000401 polarssl_printf( " Press Enter to exit this program.\n" );
Paul Bakker896ac222011-05-20 12:33:05 +0000402 fflush( stdout ); getchar();
403#endif
404
405 return( ret );
406}
Paul Bakker508ad5a2011-12-04 17:09:26 +0000407#endif /* POLARSSL_BIGNUM_C && POLARSSL_CERTS_C && POLARSSL_ENTROPY_C &&
Paul Bakker5690efc2011-05-26 13:16:06 +0000408 POLARSSL_SSL_TLS_C && POLARSSL_SSL_SRV_C && POLARSSL_NET_C &&
Paul Bakker508ad5a2011-12-04 17:09:26 +0000409 POLARSSL_RSA_C && POLARSSL_CTR_DRBG_C */