2 * Copyright (C) 2017 Denys Vlasenko
4 * Licensed under GPLv2, see file LICENSE in this source tree.
6 //config:config SSL_CLIENT
7 //config: bool "ssl_client (23 kb)"
11 //config: This tool pipes data to/from a socket, TLS-encrypting it.
13 //applet:IF_SSL_CLIENT(APPLET(ssl_client, BB_DIR_USR_BIN, BB_SUID_DROP))
15 //kbuild:lib-$(CONFIG_SSL_CLIENT) += ssl_client.o
17 //usage:#define ssl_client_trivial_usage
18 //usage: "-s FD [-r FD] [-n SNI]"
19 //usage:#define ssl_client_full_usage ""
23 int ssl_client_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
24 int ssl_client_main(int argc UNUSED_PARAM, char **argv)
27 const char *sni = NULL;
32 tls = new_tls_state();
33 opt = getopt32(argv, "s:#r:#n:", &tls->ofd, &tls->ifd, &sni);
35 /* -r N defaults to -s N */
42 /* Undocumented debug feature: without -s and -r, takes HOST arg and connects to it */
44 // Talk to kernel.org:
45 // printf "GET / HTTP/1.1\r\nHost: kernel.org\r\n\r\n" | ./busybox ssl_client kernel.org
48 tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443);
51 tls_handshake(tls, sni);
52 tls_run_copy_loop(tls);