blob: b9260bffe908b21327a055f7fd7be6c618bd09a9 [file] [log] [blame] [view]
Gilles Peskineceb7b122018-01-18 23:27:47 +01001Mbed TLS sample programs
2========================
3
4This subdirectory mostly contains sample programs that illustrate specific features of the library, as well as a few test and support programs.
5
Gilles Peskineceb7b122018-01-18 23:27:47 +01006### SSL/TLS sample applications
7
Gilles Peskine6b9cbb82018-07-30 20:06:19 +02008* [`ssl/dtls_client.c`](ssl/dtls_client.c): a simple DTLS client program, which sends one datagram to the server and reads one datagram in response.
Gilles Peskineceb7b122018-01-18 23:27:47 +01009
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020010* [`ssl/dtls_server.c`](ssl/dtls_server.c): a simple DTLS server program, which expects one datagram from the client and writes one datagram in response. This program supports DTLS cookies for hello verification.
Gilles Peskineceb7b122018-01-18 23:27:47 +010011
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020012* [`ssl/mini_client.c`](ssl/mini_client.c): a minimalistic SSL client, which sends a short string and disconnects. This is primarily intended as a benchmark; for a better example of a typical TLS client, see `ssl/ssl_client1.c`.
Gilles Peskineceb7b122018-01-18 23:27:47 +010013
14* [`ssl/ssl_client1.c`](ssl/ssl_client1.c): a simple HTTPS client that sends a fixed request and displays the response.
15
16* [`ssl/ssl_fork_server.c`](ssl/ssl_fork_server.c): a simple HTTPS server using one process per client to send a fixed response. This program requires a Unix/POSIX environment implementing the `fork` system call.
17
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020018* [`ssl/ssl_mail_client.c`](ssl/ssl_mail_client.c): a simple SMTP-over-TLS or SMTP-STARTTLS client. This client sends an email with fixed content.
Gilles Peskineceb7b122018-01-18 23:27:47 +010019
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020020* [`ssl/ssl_pthread_server.c`](ssl/ssl_pthread_server.c): a simple HTTPS server using one thread per client to send a fixed response. This program requires the pthread library.
Gilles Peskineceb7b122018-01-18 23:27:47 +010021
Gilles Peskineaa220302018-08-06 20:19:50 +020022* [`ssl/ssl_server.c`](ssl/ssl_server.c): a simple HTTPS server that sends a fixed response. It serves a single client at a time.
Gilles Peskineceb7b122018-01-18 23:27:47 +010023
24### SSL/TLS feature demonstrators
25
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020026Note: unlike most of the other programs under the `programs/` directory, these two programs are not intended as a basis for writing an application. They combine most of the features supported by the library, and most applications require only a few features. To write a new application, we recommended that you start with `ssl_client1.c` or `ssl_server.c`, and then look inside `ssl/ssl_client2.c` or `ssl/ssl_server2.c` to see how to use the specific features that your application needs.
Gilles Peskineceb7b122018-01-18 23:27:47 +010027
28* [`ssl/ssl_client2.c`](ssl/ssl_client2.c): an HTTPS client that sends a fixed request and displays the response, with options to select TLS protocol features and Mbed TLS library features.
29
30* [`ssl/ssl_server2.c`](ssl/ssl_server2.c): an HTTPS server that sends a fixed response, with options to select TLS protocol features and Mbed TLS library features.
31
Gilles Peskineaa220302018-08-06 20:19:50 +020032In addition to providing options for testing client-side features, the `ssl_client2` program has options that allow you to trigger certain behaviors in the server. For example, there are options to select ciphersuites, or to force a renegotiation. These options are useful for testing the corresponding features in a TLS server. Likewise, `ssl_server2` has options to activate certain behaviors that are useful for testing a TLS client.
Gilles Peskineceb7b122018-01-18 23:27:47 +010033
34## Test utilities
35
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020036* [`test/selftest.c`](test/selftest.c): runs the self-test function in each library module.
Gilles Peskineceb7b122018-01-18 23:27:47 +010037
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020038* [`test/udp_proxy.c`](test/udp_proxy.c): a UDP proxy that can inject certain failures (delay, duplicate, drop). Useful for testing DTLS.
Gilles Peskineceb7b122018-01-18 23:27:47 +010039
Harry Ramseyf6fb2f02025-02-18 17:52:45 +000040* [`test/zeroize.c`](../framework/tests/programs/zeroize.c): a test program for `mbedtls_platform_zeroize`, used by [`test_zeroize.gdb`](../framework/tests/programs/test_zeroize.gdb).
Gilles Peskineffbdc612018-08-10 11:48:52 +020041
Gilles Peskineceb7b122018-01-18 23:27:47 +010042## Development utilities
43
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020044* [`util/pem2der.c`](util/pem2der.c): a PEM to DER converter. Mbed TLS can read PEM files directly, but this utility can be useful for interacting with other tools or with minimal Mbed TLS builds that lack PEM support.
Gilles Peskineceb7b122018-01-18 23:27:47 +010045
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020046* [`util/strerror.c`](util/strerror.c): prints the error description corresponding to an integer status returned by an Mbed TLS function.
Gilles Peskineceb7b122018-01-18 23:27:47 +010047
48## X.509 certificate examples
49
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020050* [`x509/cert_app.c`](x509/cert_app.c): connects to a TLS server and verifies its certificate chain.
Gilles Peskineceb7b122018-01-18 23:27:47 +010051
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020052* [`x509/cert_req.c`](x509/cert_req.c): generates a certificate signing request (CSR) for a private key.
Gilles Peskineceb7b122018-01-18 23:27:47 +010053
Gilles Peskine27a04602018-08-06 20:09:16 +020054* [`x509/cert_write.c`](x509/cert_write.c): signs a certificate signing request, or self-signs a certificate.
Gilles Peskineceb7b122018-01-18 23:27:47 +010055
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020056* [`x509/crl_app.c`](x509/crl_app.c): loads and dumps a certificate revocation list (CRL).
Gilles Peskineceb7b122018-01-18 23:27:47 +010057
Gilles Peskine6b9cbb82018-07-30 20:06:19 +020058* [`x509/req_app.c`](x509/req_app.c): loads and dumps a certificate signing request (CSR).