diff options
Diffstat (limited to 'networking/ssl_client.c')
-rw-r--r-- | networking/ssl_client.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/networking/ssl_client.c b/networking/ssl_client.c index d479846d7..eb84e7726 100644 --- a/networking/ssl_client.c +++ b/networking/ssl_client.c | |||
@@ -15,7 +15,7 @@ | |||
15 | //kbuild:lib-$(CONFIG_SSL_CLIENT) += ssl_client.o | 15 | //kbuild:lib-$(CONFIG_SSL_CLIENT) += ssl_client.o |
16 | 16 | ||
17 | //usage:#define ssl_client_trivial_usage | 17 | //usage:#define ssl_client_trivial_usage |
18 | //usage: "-s FD [-r FD] [-n SNI]" | 18 | //usage: "[-e] -s FD [-r FD] [-n SNI]" |
19 | //usage:#define ssl_client_full_usage "" | 19 | //usage:#define ssl_client_full_usage "" |
20 | 20 | ||
21 | #include "libbb.h" | 21 | #include "libbb.h" |
@@ -30,26 +30,28 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv) | |||
30 | // INIT_G(); | 30 | // INIT_G(); |
31 | 31 | ||
32 | tls = new_tls_state(); | 32 | tls = new_tls_state(); |
33 | opt = getopt32(argv, "s:#r:#n:", &tls->ofd, &tls->ifd, &sni); | 33 | opt = getopt32(argv, "es:#r:#n:", &tls->ofd, &tls->ifd, &sni); |
34 | if (!(opt & 2)) { | 34 | if (!(opt & (1<<2))) { |
35 | /* -r N defaults to -s N */ | 35 | /* -r N defaults to -s N */ |
36 | tls->ifd = tls->ofd; | 36 | tls->ifd = tls->ofd; |
37 | } | 37 | } |
38 | 38 | ||
39 | if (!(opt & 3)) { | 39 | if (!(opt & (3<<1))) { |
40 | if (!argv[1]) | 40 | if (!argv[1]) |
41 | bb_show_usage(); | 41 | bb_show_usage(); |
42 | /* Undocumented debug feature: without -s and -r, takes HOST arg and connects to it */ | 42 | /* Undocumented debug feature: without -s and -r, takes HOST arg and connects to it */ |
43 | // | 43 | // |
44 | // Talk to kernel.org: | 44 | // Talk to kernel.org: |
45 | // printf "GET / HTTP/1.1\r\nHost: kernel.org\r\n\r\n" | ./busybox ssl_client kernel.org | 45 | // printf "GET / HTTP/1.1\r\nHost: kernel.org\r\n\r\n" | busybox ssl_client kernel.org |
46 | if (!sni) | 46 | if (!sni) |
47 | sni = argv[1]; | 47 | sni = argv[1]; |
48 | tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443); | 48 | tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443); |
49 | } | 49 | } |
50 | 50 | ||
51 | tls_handshake(tls, sni); | 51 | tls_handshake(tls, sni); |
52 | tls_run_copy_loop(tls); | 52 | |
53 | BUILD_BUG_ON(TLSLOOP_EXIT_ON_LOCAL_EOF != 1); | ||
54 | tls_run_copy_loop(tls, /*flags*/ opt & 1); | ||
53 | 55 | ||
54 | return EXIT_SUCCESS; | 56 | return EXIT_SUCCESS; |
55 | } | 57 | } |