blob: 8119acfa2da5f09ef35e0babdef359363ead39fb [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * SSL client demonstration program
3 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02004 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02005 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000018 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000019 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000020 */
21
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000023#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020024#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020025#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020026#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000027
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000029#include "mbedtls/platform.h"
Rich Evansf90016a2015-01-19 14:26:37 +000030#else
Rich Evans18b78c72015-02-11 14:06:19 +000031#include <stdio.h>
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020032#define mbedtls_fprintf fprintf
33#define mbedtls_printf printf
Rich Evansf90016a2015-01-19 14:26:37 +000034#endif
35
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020036#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
37 !defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \
38 !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
39 !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \
40 !defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000041int main( void )
Paul Bakker5690efc2011-05-26 13:16:06 +000042{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020043 mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or "
44 "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or "
45 "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
46 "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
Paul Bakkered27a042013-04-18 22:46:23 +020047 "not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +000048 return( 0 );
49}
50#else
Manuel Pégourié-Gonnard4b3e5ef2015-03-27 11:24:27 +010051
52#include "mbedtls/net.h"
53#include "mbedtls/debug.h"
54#include "mbedtls/ssl.h"
55#include "mbedtls/entropy.h"
56#include "mbedtls/ctr_drbg.h"
57#include "mbedtls/error.h"
58#include "mbedtls/certs.h"
59
60#include <string.h>
61
Manuel Pégourié-Gonnardc0d74942015-06-23 12:30:57 +020062#define SERVER_PORT "4433"
Manuel Pégourié-Gonnard4b3e5ef2015-03-27 11:24:27 +010063#define SERVER_NAME "localhost"
64#define GET_REQUEST "GET / HTTP/1.0\r\n\r\n"
65
66#define DEBUG_LEVEL 1
67
Manuel Pégourié-Gonnard61ee3512015-06-23 17:35:03 +020068static void my_debug( void *ctx, int level,
69 const char *file, int line,
70 const char *str )
Paul Bakker9a97c5d2013-09-15 17:07:33 +020071{
Paul Bakkerc73079a2014-04-25 16:34:30 +020072 ((void) level);
73
Manuel Pégourié-Gonnard61ee3512015-06-23 17:35:03 +020074 mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
Paul Bakkerc73079a2014-04-25 16:34:30 +020075 fflush( (FILE *) ctx );
Paul Bakker9a97c5d2013-09-15 17:07:33 +020076}
77
Rich Evans85b05ec2015-02-12 11:37:29 +000078int main( void )
Paul Bakker5121ce52009-01-03 21:22:43 +000079{
Manuel Pégourié-Gonnard5db64322015-06-30 15:40:39 +020080 int ret, len;
81 mbedtls_net_context server_fd;
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é-Gonnard5db64322015-06-30 15:40:39 +020099 mbedtls_net_init( &server_fd );
Manuel Pégourié-Gonnard41d479e2015-04-29 00:48:22 +0200100 mbedtls_ssl_init( &ssl );
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +0200101 mbedtls_ssl_config_init( &conf );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200102 mbedtls_x509_crt_init( &cacert );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200103 mbedtls_ctr_drbg_init( &ctr_drbg );
Paul Bakker5121ce52009-01-03 21:22:43 +0000104
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200105 mbedtls_printf( "\n . Seeding the random number generator..." );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000106 fflush( stdout );
107
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200108 mbedtls_entropy_init( &entropy );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200109 if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200110 (const unsigned char *) pers,
111 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000112 {
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200113 mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000114 goto exit;
115 }
116
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200117 mbedtls_printf( " ok\n" );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000118
Paul Bakker5121ce52009-01-03 21:22:43 +0000119 /*
Paul Bakker75242c32012-11-17 00:03:46 +0100120 * 0. Initialize certificates
121 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200122 mbedtls_printf( " . Loading the CA root certificate ..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100123 fflush( stdout );
124
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200125 ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
126 mbedtls_test_cas_pem_len );
Paul Bakker75242c32012-11-17 00:03:46 +0100127 if( ret < 0 )
128 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200129 mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100130 goto exit;
131 }
132
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200133 mbedtls_printf( " ok (%d skipped)\n", ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100134
135 /*
Paul Bakker5121ce52009-01-03 21:22:43 +0000136 * 1. Start the connection
137 */
Manuel Pégourié-Gonnardc0d74942015-06-23 12:30:57 +0200138 mbedtls_printf( " . Connecting to tcp/%s/%s...", SERVER_NAME, SERVER_PORT );
Paul Bakker5121ce52009-01-03 21:22:43 +0000139 fflush( stdout );
140
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200141 if( ( ret = mbedtls_net_connect( &server_fd, SERVER_NAME,
142 SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000143 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200144 mbedtls_printf( " failed\n ! mbedtls_net_connect returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000145 goto exit;
146 }
147
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200148 mbedtls_printf( " ok\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000149
150 /*
151 * 2. Setup stuff
152 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200153 mbedtls_printf( " . Setting up the SSL/TLS structure..." );
Paul Bakker5121ce52009-01-03 21:22:43 +0000154 fflush( stdout );
155
Manuel Pégourié-Gonnard419d5ae2015-05-04 19:32:36 +0200156 if( ( ret = mbedtls_ssl_config_defaults( &conf,
157 MBEDTLS_SSL_IS_CLIENT,
Manuel Pégourié-Gonnardb31c5f62015-06-17 13:53:47 +0200158 MBEDTLS_SSL_TRANSPORT_STREAM,
159 MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
Manuel Pégourié-Gonnarddef0bbe2015-05-04 14:56:36 +0200160 {
161 mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret );
162 goto exit;
163 }
164
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200165 mbedtls_printf( " ok\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000166
Manuel Pégourié-Gonnardfcf2fc22014-03-11 11:10:27 +0100167 /* OPTIONAL is not optimal for security,
168 * but makes interop easier in this simplified example */
Manuel Pégourié-Gonnard6729e792015-05-11 09:50:24 +0200169 mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
170 mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
Manuel Pégourié-Gonnard06939ce2015-05-11 11:25:46 +0200171 mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
172 mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
173
174 if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
175 {
176 mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
177 goto exit;
178 }
179
Paul Bakkerc60c3122016-07-22 11:54:30 +0100180 if( ( ret = mbedtls_ssl_set_hostname( &ssl, SERVER_NAME ) ) != 0 )
Manuel Pégourié-Gonnardbc2b7712015-05-06 11:14:19 +0100181 {
182 mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret );
183 goto exit;
184 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000185
Manuel Pégourié-Gonnard1b511f92015-05-06 15:54:23 +0100186 mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL );
Paul Bakker5121ce52009-01-03 21:22:43 +0000187
Paul Bakker5121ce52009-01-03 21:22:43 +0000188 /*
Paul Bakker75242c32012-11-17 00:03:46 +0100189 * 4. Handshake
190 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200191 mbedtls_printf( " . Performing the SSL/TLS handshake..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100192 fflush( stdout );
193
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200194 while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 )
Paul Bakker75242c32012-11-17 00:03:46 +0100195 {
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100196 if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker75242c32012-11-17 00:03:46 +0100197 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200198 mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret );
Paul Bakker75242c32012-11-17 00:03:46 +0100199 goto exit;
200 }
201 }
202
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200203 mbedtls_printf( " ok\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100204
205 /*
206 * 5. Verify the server certificate
207 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200208 mbedtls_printf( " . Verifying peer X.509 certificate..." );
Paul Bakker75242c32012-11-17 00:03:46 +0100209
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100210 /* In real life, we probably want to bail out when ret != 0 */
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200211 if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 )
Paul Bakker75242c32012-11-17 00:03:46 +0100212 {
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100213 char vrfy_buf[512];
214
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200215 mbedtls_printf( " failed\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100216
Manuel Pégourié-Gonnarde6ef16f2015-05-11 19:54:43 +0200217 mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags );
Paul Bakker75242c32012-11-17 00:03:46 +0100218
Manuel Pégourié-Gonnard89addc42015-04-20 10:56:18 +0100219 mbedtls_printf( "%s\n", vrfy_buf );
Paul Bakker75242c32012-11-17 00:03:46 +0100220 }
221 else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200222 mbedtls_printf( " ok\n" );
Paul Bakker75242c32012-11-17 00:03:46 +0100223
224 /*
Paul Bakker5121ce52009-01-03 21:22:43 +0000225 * 3. Write the GET request
226 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200227 mbedtls_printf( " > Write to server:" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000228 fflush( stdout );
229
230 len = sprintf( (char *) buf, GET_REQUEST );
231
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200232 while( ( ret = mbedtls_ssl_write( &ssl, buf, len ) ) <= 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000233 {
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100234 if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000235 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236 mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000237 goto exit;
238 }
239 }
240
241 len = ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200242 mbedtls_printf( " %d bytes written\n\n%s", len, (char *) buf );
Paul Bakker5121ce52009-01-03 21:22:43 +0000243
244 /*
245 * 7. Read the HTTP response
246 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200247 mbedtls_printf( " < Read from server:" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000248 fflush( stdout );
249
250 do
251 {
252 len = sizeof( buf ) - 1;
253 memset( buf, 0, sizeof( buf ) );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254 ret = mbedtls_ssl_read( &ssl, buf, len );
Paul Bakker5121ce52009-01-03 21:22:43 +0000255
Manuel Pégourié-Gonnard88369942015-05-06 16:19:31 +0100256 if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000257 continue;
258
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200259 if( ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY )
Paul Bakker5121ce52009-01-03 21:22:43 +0000260 break;
261
Paul Bakker61da7522011-11-11 10:28:58 +0000262 if( ret < 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000263 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200264 mbedtls_printf( "failed\n ! mbedtls_ssl_read returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000265 break;
266 }
267
Paul Bakker61da7522011-11-11 10:28:58 +0000268 if( ret == 0 )
269 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200270 mbedtls_printf( "\n\nEOF\n\n" );
Paul Bakker61da7522011-11-11 10:28:58 +0000271 break;
272 }
273
Paul Bakker5121ce52009-01-03 21:22:43 +0000274 len = ret;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200275 mbedtls_printf( " %d bytes read\n\n%s", len, (char *) buf );
Paul Bakker5121ce52009-01-03 21:22:43 +0000276 }
Paul Bakker61da7522011-11-11 10:28:58 +0000277 while( 1 );
Paul Bakker5121ce52009-01-03 21:22:43 +0000278
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200279 mbedtls_ssl_close_notify( &ssl );
Paul Bakker5121ce52009-01-03 21:22:43 +0000280
281exit:
282
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200283#ifdef MBEDTLS_ERROR_C
Paul Bakkera3d195c2011-11-27 21:07:34 +0000284 if( ret != 0 )
285 {
286 char error_buf[100];
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200287 mbedtls_strerror( ret, error_buf, 100 );
288 mbedtls_printf("Last error was: %d - %s\n\n", ret, error_buf );
Paul Bakkera3d195c2011-11-27 21:07:34 +0000289 }
290#endif
291
Manuel Pégourié-Gonnard3d7d00a2015-06-30 15:55:03 +0200292 mbedtls_net_free( &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 */