blob: c23c65323a68e34c1bc4917f95f89f0bda0dacb4 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * SSL client demonstration program
3 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00004 * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00005 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +00006 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 *
Paul Bakker5121ce52009-01-03 21:22:43 +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é-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000024#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020025#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020027#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000028
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030#include "mbedtls/platform.h"
Rich Evansf90016a2015-01-19 14:26:37 +000031#else
Rich Evans18b78c72015-02-11 14:06:19 +000032#include <stdio.h>
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#define mbedtls_fprintf fprintf
34#define mbedtls_printf printf
Rich Evansf90016a2015-01-19 14:26:37 +000035#endif
36
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
38 !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \
39 !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
40 !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \
41 !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000042int main( void )
Paul Bakker5690efc2011-05-26 13:16:06 +000043{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020044 mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or "
45 "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or "
46 "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
47 "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
Paul Bakkered27a042013-04-18 22:46:23 +020048 "not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +000049 return( 0 );
50}
51#else
Manuel Pégourié-Gonnard4b3e5ef2015-03-27 11:24:27 +010052
53#include "mbedtls/net.h"
54#include "mbedtls/debug.h"
55#include "mbedtls/ssl.h"
56#include "mbedtls/entropy.h"
57#include "mbedtls/ctr_drbg.h"
58#include "mbedtls/error.h"
59#include "mbedtls/certs.h"
60
61#include <string.h>
62
Manuel Pégourié-Gonnardc0d74942015-06-23 12:30:57 +020063#define SERVER_PORT "4433"
Manuel Pégourié-Gonnard4b3e5ef2015-03-27 11:24:27 +010064#define SERVER_NAME "localhost"
65#define GET_REQUEST "GET / HTTP/1.0\r\n\r\n"
66
67#define DEBUG_LEVEL 1
68
Manuel Pégourié-Gonnard61ee3512015-06-23 17:35:03 +020069static void my_debug( void *ctx, int level,
70 const char *file, int line,
71 const char *str )
Paul Bakker9a97c5d2013-09-15 17:07:33 +020072{
Paul Bakkerc73079a2014-04-25 16:34:30 +020073 ((void) level);
74
Manuel Pégourié-Gonnard61ee3512015-06-23 17:35:03 +020075 mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
Paul Bakkerc73079a2014-04-25 16:34:30 +020076 fflush( (FILE *) ctx );
Paul Bakker9a97c5d2013-09-15 17:07:33 +020077}
78
Rich Evans85b05ec2015-02-12 11:37:29 +000079int main( void )
Paul Bakker5121ce52009-01-03 21:22:43 +000080{
Manuel Pégourié-Gonnard68821da2013-09-16 12:34:33 +020081 int ret, len, server_fd = -1;
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +020082 uint32_t flags;
Paul Bakker5121ce52009-01-03 21:22:43 +000083 unsigned char buf[1024];
Paul Bakkeref3f8c72013-06-24 13:01:08 +020084 const char *pers = "ssl_client1";
Paul Bakker508ad5a2011-12-04 17:09:26 +000085
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086 mbedtls_entropy_context entropy;
87 mbedtls_ctr_drbg_context ctr_drbg;
88 mbedtls_ssl_context ssl;
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +020089 mbedtls_ssl_config conf;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020090 mbedtls_x509_crt cacert;
Paul Bakker5121ce52009-01-03 21:22:43 +000091
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020092#if defined(MBEDTLS_DEBUG_C)
93 mbedtls_debug_set_threshold( DEBUG_LEVEL );
Paul Bakkerc73079a2014-04-25 16:34:30 +020094#endif
95
Paul Bakker5121ce52009-01-03 21:22:43 +000096 /*
97 * 0. Initialize the RNG and the session data
98 */
Manuel Pégourié-Gonnard41d479e2015-04-29 00:48:22 +020099 mbedtls_ssl_init( &ssl );
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +0200100 mbedtls_ssl_config_init( &conf );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200101 mbedtls_x509_crt_init( &cacert );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200102 mbedtls_ctr_drbg_init( &ctr_drbg );
Paul Bakker5121ce52009-01-03 21:22:43 +0000103
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200104 mbedtls_printf( "\n . Seeding the random number generator..." );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000105 fflush( stdout );
106
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200107 mbedtls_entropy_init( &entropy );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200108 if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200109 (const unsigned char *) pers,
110 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000111 {
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200112 mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000113 goto exit;
114 }
115
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200116 mbedtls_printf( " ok\n" );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000117
Paul Bakker5121ce52009-01-03 21:22:43 +0000118 /*
Paul Bakker75242c32012-11-17 00:03:46 +0100119 * 0. Initialize certificates
120 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200121 mbedtls_printf( " . Loading the CA root certificate ..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100122 fflush( stdout );
123
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200124 ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
125 mbedtls_test_cas_pem_len );
Paul Bakker75242c32012-11-17 00:03:46 +0100126 if( ret < 0 )
127 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200128 mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100129 goto exit;
130 }
131
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200132 mbedtls_printf( " ok (%d skipped)\n", ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100133
134 /*
Paul Bakker5121ce52009-01-03 21:22:43 +0000135 * 1. Start the connection
136 */
Manuel Pégourié-Gonnardc0d74942015-06-23 12:30:57 +0200137 mbedtls_printf( " . Connecting to tcp/%s/%s...", SERVER_NAME, SERVER_PORT );
Paul Bakker5121ce52009-01-03 21:22:43 +0000138 fflush( stdout );
139
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200140 if( ( ret = mbedtls_net_connect( &server_fd, SERVER_NAME,
141 SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000142 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200143 mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000144 goto exit;
145 }
146
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200147 mbedtls_printf( " ok\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000148
149 /*
150 * 2. Setup stuff
151 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200152 mbedtls_printf( " . Setting up the SSL/TLS structure..." );
Paul Bakker5121ce52009-01-03 21:22:43 +0000153 fflush( stdout );
154
Manuel Pégourié-Gonnard419d5ae2015-05-04 19:32:36 +0200155 if( ( ret = mbedtls_ssl_config_defaults( &conf,
156 MBEDTLS_SSL_IS_CLIENT,
Manuel Pégourié-Gonnardb31c5f62015-06-17 13:53:47 +0200157 MBEDTLS_SSL_TRANSPORT_STREAM,
158 MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +0200159 {
160 mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret );
161 goto exit;
162 }
163
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200164 mbedtls_printf( " ok\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000165
Manuel Pégourié-Gonnardfcf2fc22014-03-11 11:10:27 +0100166 /* OPTIONAL is not optimal for security,
167 * but makes interop easier in this simplified example */
Manuel Pégourié-Gonnard6729e792015-05-11 09:50:24 +0200168 mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
169 mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
Manuel Pégourié-Gonnard06939ce2015-05-11 11:25:46 +0200170 mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
171 mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
172
173 if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
174 {
175 mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
176 goto exit;
177 }
178
Manuel Pégourié-Gonnardbc2b7712015-05-06 11:14:19 +0100179 if( ( ret = mbedtls_ssl_set_hostname( &ssl, "mbed TLS Server 1" ) ) != 0 )
180 {
181 mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret );
182 goto exit;
183 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000184
Manuel Pégourié-Gonnard1b511f92015-05-06 15:54:23 +0100185 mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL );
Paul Bakker5121ce52009-01-03 21:22:43 +0000186
Paul Bakker5121ce52009-01-03 21:22:43 +0000187 /*
Paul Bakker75242c32012-11-17 00:03:46 +0100188 * 4. Handshake
189 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190 mbedtls_printf( " . Performing the SSL/TLS handshake..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100191 fflush( stdout );
192
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200193 while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 )
Paul Bakker75242c32012-11-17 00:03:46 +0100194 {
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100195 if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker75242c32012-11-17 00:03:46 +0100196 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200197 mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100198 goto exit;
199 }
200 }
201
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200202 mbedtls_printf( " ok\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100203
204 /*
205 * 5. Verify the server certificate
206 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200207 mbedtls_printf( " . Verifying peer X.509 certificate..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100208
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100209 /* In real life, we probably want to bail out when ret != 0 */
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200210 if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 )
Paul Bakker75242c32012-11-17 00:03:46 +0100211 {
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100212 char vrfy_buf[512];
213
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200214 mbedtls_printf( " failed\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100215
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200216 mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags );
Paul Bakker75242c32012-11-17 00:03:46 +0100217
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100218 mbedtls_printf( "%s\n", vrfy_buf );
Paul Bakker75242c32012-11-17 00:03:46 +0100219 }
220 else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200221 mbedtls_printf( " ok\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100222
223 /*
Paul Bakker5121ce52009-01-03 21:22:43 +0000224 * 3. Write the GET request
225 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200226 mbedtls_printf( " > Write to server:" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000227 fflush( stdout );
228
229 len = sprintf( (char *) buf, GET_REQUEST );
230
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200231 while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000232 {
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100233 if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000234 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200235 mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000236 goto exit;
237 }
238 }
239
240 len = ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200241 mbedtls_printf( " %d bytes written\n\n%s", len, (char *) buf );
Paul Bakker5121ce52009-01-03 21:22:43 +0000242
243 /*
244 * 7. Read the HTTP response
245 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200246 mbedtls_printf( " < Read from server:" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000247 fflush( stdout );
248
249 do
250 {
251 len = sizeof( buf ) - 1;
252 memset( buf, 0, sizeof( buf ) );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200253 ret = mbedtls_ssl_read( &ssl, buf, len );
Paul Bakker5121ce52009-01-03 21:22:43 +0000254
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100255 if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000256 continue;
257
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200258 if( ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY )
Paul Bakker5121ce52009-01-03 21:22:43 +0000259 break;
260
Paul Bakker61da7522011-11-11 10:28:58 +0000261 if( ret < 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000262 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200263 mbedtls_printf( "failed\n ! mbedtls_ssl_read returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000264 break;
265 }
266
Paul Bakker61da7522011-11-11 10:28:58 +0000267 if( ret == 0 )
268 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200269 mbedtls_printf( "\n\nEOF\n\n" );
Paul Bakker61da7522011-11-11 10:28:58 +0000270 break;
271 }
272
Paul Bakker5121ce52009-01-03 21:22:43 +0000273 len = ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200274 mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf );
Paul Bakker5121ce52009-01-03 21:22:43 +0000275 }
Paul Bakker61da7522011-11-11 10:28:58 +0000276 while( 1 );
Paul Bakker5121ce52009-01-03 21:22:43 +0000277
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200278 mbedtls_ssl_close_notify( &ssl );
Paul Bakker5121ce52009-01-03 21:22:43 +0000279
280exit:
281
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200282#ifdef MBEDTLS_ERROR_C
Paul Bakkera3d195c2011-11-27 21:07:34 +0000283 if( ret != 0 )
284 {
285 char error_buf[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200286 mbedtls_strerror( ret, error_buf, 100 );
287 mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf );
Paul Bakkera3d195c2011-11-27 21:07:34 +0000288 }
289#endif
290
Paul Bakker0c226102014-04-17 16:02:36 +0200291 if( server_fd != -1 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200292 mbedtls_net_close( server_fd );
Paul Bakker0c226102014-04-17 16:02:36 +0200293
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200294 mbedtls_x509_crt_free( &cacert );
295 mbedtls_ssl_free( &ssl );
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +0200296 mbedtls_ssl_config_free( &conf );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200297 mbedtls_ctr_drbg_free( &ctr_drbg );
298 mbedtls_entropy_free( &entropy );
Paul Bakker5121ce52009-01-03 21:22:43 +0000299
Paul Bakkercce9d772011-11-18 14:26:47 +0000300#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200301 mbedtls_printf( " + Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000302 fflush( stdout ); getchar();
303#endif
304
305 return( ret );
306}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200307#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
308 MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&
309 MBEDTLS_CERTS_C && MBEDTLS_PEM_PARSE_C && MBEDTLS_CTR_DRBG_C &&
310 MBEDTLS_X509_CRT_PARSE_C */