Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 1 | /* |
Paul Bakker | cb79ae0b | 2011-05-20 12:44:16 +0000 | [diff] [blame] | 2 | * SSL server demonstration program using fork() for handling multiple clients |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 3c5ef71 | 2013-06-25 16:37:45 +0200 | [diff] [blame] | 4 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 5 | * |
| 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | */ |
| 25 | |
Manuel Pégourié-Gonnard | abd6e02 | 2013-09-20 13:30:43 +0200 | [diff] [blame] | 26 | #include "polarssl/config.h" |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 27 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 28 | #if defined(_WIN32) |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 29 | #include <windows.h> |
| 30 | #endif |
| 31 | |
| 32 | #include <string.h> |
| 33 | #include <stdlib.h> |
| 34 | #include <stdio.h> |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 35 | #include <signal.h> |
| 36 | |
Paul Bakker | fdda785 | 2013-11-30 15:15:31 +0100 | [diff] [blame] | 37 | #if !defined(_MSC_VER) || defined(EFIX64) || defined(EFI32) |
| 38 | #include <unistd.h> |
| 39 | #endif |
| 40 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 41 | #include "polarssl/entropy.h" |
| 42 | #include "polarssl/ctr_drbg.h" |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 43 | #include "polarssl/certs.h" |
| 44 | #include "polarssl/x509.h" |
| 45 | #include "polarssl/ssl.h" |
| 46 | #include "polarssl/net.h" |
| 47 | #include "polarssl/timing.h" |
| 48 | |
| 49 | #define HTTP_RESPONSE \ |
| 50 | "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ |
| 51 | "<h2>PolarSSL Test Server</h2>\r\n" \ |
| 52 | "<p>Successful connection using: %s</p>\r\n" |
| 53 | |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 54 | #if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_CERTS_C) || \ |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 55 | !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_SSL_TLS_C) || \ |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 56 | !defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) || \ |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 57 | !defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \ |
Paul Bakker | 36713e8 | 2013-09-17 13:25:29 +0200 | [diff] [blame] | 58 | !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_TIMING_C) |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 59 | int main( int argc, char *argv[] ) |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 60 | { |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 61 | ((void) argc); |
| 62 | ((void) argv); |
| 63 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 64 | printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_ENTROPY_C " |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 65 | "and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or " |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 66 | "POLARSSL_NET_C and/or POLARSSL_RSA_C and/or " |
Paul Bakker | 36713e8 | 2013-09-17 13:25:29 +0200 | [diff] [blame] | 67 | "POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C and/or " |
Paul Bakker | fa9b100 | 2013-07-03 15:31:03 +0200 | [diff] [blame] | 68 | "POLARSSL_TIMING_C not defined.\n"); |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 69 | return( 0 ); |
| 70 | } |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 71 | #elif defined(_WIN32) |
| 72 | int main( int argc, char *argv[] ) |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 73 | { |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 74 | ((void) argc); |
| 75 | ((void) argv); |
| 76 | |
| 77 | printf("_WIN32 defined. This application requires fork() and signals " |
Paul Bakker | b892b13 | 2011-10-12 09:19:43 +0000 | [diff] [blame] | 78 | "to work correctly.\n"); |
| 79 | return( 0 ); |
| 80 | } |
| 81 | #else |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 82 | |
| 83 | #define DEBUG_LEVEL 0 |
| 84 | |
Paul Bakker | 3c5ef71 | 2013-06-25 16:37:45 +0200 | [diff] [blame] | 85 | static void my_debug( void *ctx, int level, const char *str ) |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 86 | { |
| 87 | if( level < DEBUG_LEVEL ) |
| 88 | { |
| 89 | fprintf( (FILE *) ctx, "%s", str ); |
| 90 | fflush( (FILE *) ctx ); |
| 91 | } |
| 92 | } |
| 93 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 94 | int main( int argc, char *argv[] ) |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 95 | { |
| 96 | int ret, len, cnt = 0, pid; |
| 97 | int listen_fd; |
Manuel Pégourié-Gonnard | 68821da | 2013-09-16 12:34:33 +0200 | [diff] [blame] | 98 | int client_fd = -1; |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 99 | unsigned char buf[1024]; |
Paul Bakker | ef3f8c7 | 2013-06-24 13:01:08 +0200 | [diff] [blame] | 100 | const char *pers = "ssl_fork_server"; |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 101 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 102 | entropy_context entropy; |
| 103 | ctr_drbg_context ctr_drbg; |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 104 | ssl_context ssl; |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 105 | x509_crt srvcert; |
Manuel Pégourié-Gonnard | ac75523 | 2013-08-19 14:10:16 +0200 | [diff] [blame] | 106 | pk_context pkey; |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 107 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 108 | ((void) argc); |
| 109 | ((void) argv); |
| 110 | |
Paul Bakker | 0c22610 | 2014-04-17 16:02:36 +0200 | [diff] [blame^] | 111 | memset( &ssl, 0, sizeof(ssl_context) ); |
| 112 | |
| 113 | entropy_init( &entropy ); |
| 114 | pk_init( &pkey ); |
| 115 | x509_crt_init( &srvcert ); |
| 116 | |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 117 | signal( SIGCHLD, SIG_IGN ); |
| 118 | |
| 119 | /* |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 120 | * 0. Initial seeding of the RNG |
| 121 | */ |
| 122 | printf( "\n . Initial seeding of the random generator..." ); |
| 123 | fflush( stdout ); |
| 124 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 125 | if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy, |
Paul Bakker | ef3f8c7 | 2013-06-24 13:01:08 +0200 | [diff] [blame] | 126 | (const unsigned char *) pers, |
| 127 | strlen( pers ) ) ) != 0 ) |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 128 | { |
| 129 | printf( " failed\n ! ctr_drbg_init returned %d\n", ret ); |
| 130 | goto exit; |
| 131 | } |
| 132 | |
| 133 | printf( " ok\n" ); |
| 134 | |
| 135 | /* |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 136 | * 1. Load the certificates and private RSA key |
| 137 | */ |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 138 | printf( " . Loading the server cert. and key..." ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 139 | fflush( stdout ); |
| 140 | |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 141 | /* |
| 142 | * This demonstration program uses embedded test certificates. |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 143 | * Instead, you may want to use x509_crt_parse_file() to read the |
| 144 | * server and CA certificates, as well as pk_parse_keyfile(). |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 145 | */ |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 146 | ret = x509_crt_parse( &srvcert, (const unsigned char *) test_srv_crt, |
| 147 | strlen( test_srv_crt ) ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 148 | if( ret != 0 ) |
| 149 | { |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 150 | printf( " failed\n ! x509_crt_parse returned %d\n\n", ret ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 151 | goto exit; |
| 152 | } |
| 153 | |
Manuel Pégourié-Gonnard | 641de71 | 2013-09-25 13:23:33 +0200 | [diff] [blame] | 154 | ret = x509_crt_parse( &srvcert, (const unsigned char *) test_ca_list, |
| 155 | strlen( test_ca_list ) ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 156 | if( ret != 0 ) |
| 157 | { |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 158 | printf( " failed\n ! x509_crt_parse returned %d\n\n", ret ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 159 | goto exit; |
| 160 | } |
| 161 | |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 162 | ret = pk_parse_key( &pkey, (const unsigned char *) test_srv_key, |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 163 | strlen( test_srv_key ), NULL, 0 ); |
| 164 | if( ret != 0 ) |
| 165 | { |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 166 | printf( " failed\n ! pk_parse_key returned %d\n\n", ret ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 167 | goto exit; |
| 168 | } |
| 169 | |
| 170 | printf( " ok\n" ); |
| 171 | |
| 172 | /* |
| 173 | * 2. Setup the listening TCP socket |
| 174 | */ |
| 175 | printf( " . Bind on https://localhost:4433/ ..." ); |
| 176 | fflush( stdout ); |
| 177 | |
| 178 | if( ( ret = net_bind( &listen_fd, NULL, 4433 ) ) != 0 ) |
| 179 | { |
| 180 | printf( " failed\n ! net_bind returned %d\n\n", ret ); |
| 181 | goto exit; |
| 182 | } |
| 183 | |
| 184 | printf( " ok\n" ); |
| 185 | |
| 186 | while( 1 ) |
| 187 | { |
| 188 | /* |
| 189 | * 3. Wait until a client connects |
| 190 | */ |
| 191 | client_fd = -1; |
| 192 | memset( &ssl, 0, sizeof( ssl ) ); |
| 193 | |
| 194 | printf( " . Waiting for a remote connection ..." ); |
| 195 | fflush( stdout ); |
| 196 | |
| 197 | if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 ) |
| 198 | { |
| 199 | printf( " failed\n ! net_accept returned %d\n\n", ret ); |
| 200 | goto exit; |
| 201 | } |
| 202 | |
| 203 | printf( " ok\n" ); |
| 204 | |
| 205 | /* |
| 206 | * 3.5. Forking server thread |
| 207 | */ |
| 208 | |
| 209 | pid = fork(); |
| 210 | |
| 211 | printf( " . Forking to handle connection ..." ); |
| 212 | fflush( stdout ); |
| 213 | |
| 214 | if( pid < 0 ) |
| 215 | { |
| 216 | printf(" failed\n ! fork returned %d\n\n", pid ); |
| 217 | goto exit; |
| 218 | } |
| 219 | |
| 220 | printf( " ok\n" ); |
| 221 | |
| 222 | if( pid != 0 ) |
| 223 | { |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 224 | if( ( ret = ctr_drbg_reseed( &ctr_drbg, |
Paul Bakker | ef3f8c7 | 2013-06-24 13:01:08 +0200 | [diff] [blame] | 225 | (const unsigned char *) "parent", |
| 226 | 6 ) ) != 0 ) |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 227 | { |
| 228 | printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret ); |
| 229 | goto exit; |
| 230 | } |
| 231 | |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 232 | close( client_fd ); |
| 233 | continue; |
| 234 | } |
| 235 | |
| 236 | close( listen_fd ); |
| 237 | |
| 238 | /* |
| 239 | * 4. Setup stuff |
| 240 | */ |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 241 | printf( " . Setting up the SSL data...." ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 242 | fflush( stdout ); |
| 243 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 244 | if( ( ret = ctr_drbg_reseed( &ctr_drbg, |
Paul Bakker | ef3f8c7 | 2013-06-24 13:01:08 +0200 | [diff] [blame] | 245 | (const unsigned char *) "child", |
| 246 | 5 ) ) != 0 ) |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 247 | { |
| 248 | printf( " failed\n ! ctr_drbg_reseed returned %d\n", ret ); |
| 249 | goto exit; |
| 250 | } |
Paul Bakker | 0c22610 | 2014-04-17 16:02:36 +0200 | [diff] [blame^] | 251 | |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 252 | if( ( ret = ssl_init( &ssl ) ) != 0 ) |
| 253 | { |
| 254 | printf( " failed\n ! ssl_init returned %d\n\n", ret ); |
| 255 | goto exit; |
| 256 | } |
| 257 | |
| 258 | printf( " ok\n" ); |
| 259 | |
| 260 | ssl_set_endpoint( &ssl, SSL_IS_SERVER ); |
| 261 | ssl_set_authmode( &ssl, SSL_VERIFY_NONE ); |
| 262 | |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 263 | ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 264 | ssl_set_dbg( &ssl, my_debug, stdout ); |
| 265 | ssl_set_bio( &ssl, net_recv, &client_fd, |
| 266 | net_send, &client_fd ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 267 | |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 268 | ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL ); |
Manuel Pégourié-Gonnard | ac75523 | 2013-08-19 14:10:16 +0200 | [diff] [blame] | 269 | ssl_set_own_cert( &ssl, &srvcert, &pkey ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 270 | |
| 271 | /* |
| 272 | * 5. Handshake |
| 273 | */ |
| 274 | printf( " . Performing the SSL/TLS handshake..." ); |
| 275 | fflush( stdout ); |
| 276 | |
| 277 | while( ( ret = ssl_handshake( &ssl ) ) != 0 ) |
| 278 | { |
| 279 | if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE ) |
| 280 | { |
| 281 | printf( " failed\n ! ssl_handshake returned %d\n\n", ret ); |
| 282 | goto exit; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | printf( " ok\n" ); |
| 287 | |
| 288 | /* |
| 289 | * 6. Read the HTTP Request |
| 290 | */ |
| 291 | printf( " < Read from client:" ); |
| 292 | fflush( stdout ); |
| 293 | |
| 294 | do |
| 295 | { |
| 296 | len = sizeof( buf ) - 1; |
| 297 | memset( buf, 0, sizeof( buf ) ); |
| 298 | ret = ssl_read( &ssl, buf, len ); |
| 299 | |
| 300 | if( ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE ) |
| 301 | continue; |
| 302 | |
| 303 | if( ret <= 0 ) |
| 304 | { |
| 305 | switch( ret ) |
| 306 | { |
| 307 | case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY: |
| 308 | printf( " connection was closed gracefully\n" ); |
| 309 | break; |
| 310 | |
| 311 | case POLARSSL_ERR_NET_CONN_RESET: |
| 312 | printf( " connection was reset by peer\n" ); |
| 313 | break; |
| 314 | |
| 315 | default: |
| 316 | printf( " ssl_read returned %d\n", ret ); |
| 317 | break; |
| 318 | } |
| 319 | |
| 320 | break; |
| 321 | } |
| 322 | |
| 323 | len = ret; |
| 324 | printf( " %d bytes read\n\n%s", len, (char *) buf ); |
| 325 | } |
| 326 | while( 0 ); |
| 327 | |
| 328 | /* |
| 329 | * 7. Write the 200 Response |
| 330 | */ |
| 331 | printf( " > Write to client:" ); |
| 332 | fflush( stdout ); |
| 333 | |
| 334 | len = sprintf( (char *) buf, HTTP_RESPONSE, |
| 335 | ssl_get_ciphersuite( &ssl ) ); |
| 336 | |
| 337 | while( cnt < 100 ) |
| 338 | { |
| 339 | while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 ) |
| 340 | { |
| 341 | if( ret == POLARSSL_ERR_NET_CONN_RESET ) |
| 342 | { |
| 343 | printf( " failed\n ! peer closed the connection\n\n" ); |
| 344 | goto exit; |
| 345 | } |
| 346 | |
| 347 | if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE ) |
| 348 | { |
| 349 | printf( " failed\n ! ssl_write returned %d\n\n", ret ); |
| 350 | goto exit; |
| 351 | } |
| 352 | } |
| 353 | len = ret; |
| 354 | printf( " %d bytes written\n\n%s\n", len, (char *) buf ); |
| 355 | |
| 356 | m_sleep( 1000 ); |
| 357 | } |
| 358 | |
| 359 | ssl_close_notify( &ssl ); |
| 360 | goto exit; |
| 361 | } |
| 362 | |
| 363 | exit: |
| 364 | |
Paul Bakker | 0c22610 | 2014-04-17 16:02:36 +0200 | [diff] [blame^] | 365 | if( client_fd != -1 ) |
| 366 | net_close( client_fd ); |
| 367 | |
Paul Bakker | 36713e8 | 2013-09-17 13:25:29 +0200 | [diff] [blame] | 368 | x509_crt_free( &srvcert ); |
Manuel Pégourié-Gonnard | ac75523 | 2013-08-19 14:10:16 +0200 | [diff] [blame] | 369 | pk_free( &pkey ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 370 | ssl_free( &ssl ); |
Paul Bakker | 1ffefac | 2013-09-28 15:23:03 +0200 | [diff] [blame] | 371 | entropy_free( &entropy ); |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 372 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 373 | #if defined(_WIN32) |
Paul Bakker | 896ac22 | 2011-05-20 12:33:05 +0000 | [diff] [blame] | 374 | printf( " Press Enter to exit this program.\n" ); |
| 375 | fflush( stdout ); getchar(); |
| 376 | #endif |
| 377 | |
| 378 | return( ret ); |
| 379 | } |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 380 | #endif /* POLARSSL_BIGNUM_C && POLARSSL_CERTS_C && POLARSSL_ENTROPY_C && |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 381 | POLARSSL_SSL_TLS_C && POLARSSL_SSL_SRV_C && POLARSSL_NET_C && |
Paul Bakker | 508ad5a | 2011-12-04 17:09:26 +0000 | [diff] [blame] | 382 | POLARSSL_RSA_C && POLARSSL_CTR_DRBG_C */ |