aboutsummaryrefslogtreecommitdiff
path: root/networking/ssl_client.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-03-15 10:32:23 +0000
committerRon Yorston <rmy@pobox.com>2018-03-15 10:39:20 +0000
commit7cc082e2370da69c8783812c251190d316ce82b3 (patch)
tree8a6224f8dd28fb1ffd3e6ef111efcc8b82f429b8 /networking/ssl_client.c
parentf011d7284d8cabe5d453b43d4df44d0423db22c8 (diff)
downloadbusybox-w32-7cc082e2370da69c8783812c251190d316ce82b3.tar.gz
busybox-w32-7cc082e2370da69c8783812c251190d316ce82b3.tar.bz2
busybox-w32-7cc082e2370da69c8783812c251190d316ce82b3.zip
wget: add support for https
Allow wget to support https URLs. Changes are: - Add mingw_popen2 which uses a named pipe to allow bidirectional communication with a child process; - Modify ssl_client to accept a WIN32 handle instead of a file descriptor as an argument; - Allow tls_get_random to open /dev/urandom; - Using the above changes implement a WIN32 version of spawn_ssl_client in wget. This closes GitHub issue #75. Also, enable authentication in wget.
Diffstat (limited to 'networking/ssl_client.c')
-rw-r--r--networking/ssl_client.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/networking/ssl_client.c b/networking/ssl_client.c
index eb84e7726..e56d82fc1 100644
--- a/networking/ssl_client.c
+++ b/networking/ssl_client.c
@@ -15,7 +15,12 @@
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: IF_NOT_PLATFORM_MINGW32(
18//usage: "[-e] -s FD [-r FD] [-n SNI]" 19//usage: "[-e] -s FD [-r FD] [-n SNI]"
20//usage: )
21//usage: IF_PLATFORM_MINGW32(
22//usage: "[-e] -h handle [-n SNI]"
23//usage: )
19//usage:#define ssl_client_full_usage "" 24//usage:#define ssl_client_full_usage ""
20 25
21#include "libbb.h" 26#include "libbb.h"
@@ -26,15 +31,24 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv)
26 tls_state_t *tls; 31 tls_state_t *tls;
27 const char *sni = NULL; 32 const char *sni = NULL;
28 int opt; 33 int opt;
34#if ENABLE_PLATFORM_MINGW32
35 char *hstr = NULL;
36 HANDLE h;
37#endif
29 38
30 // INIT_G(); 39 // INIT_G();
31 40
32 tls = new_tls_state(); 41 tls = new_tls_state();
33 opt = getopt32(argv, "es:#r:#n:", &tls->ofd, &tls->ifd, &sni); 42#if !ENABLE_PLATFORM_MINGW32
43 opt = getopt32(argv, "es:+r:+n:", &tls->ofd, &tls->ifd, &sni);
44
34 if (!(opt & (1<<2))) { 45 if (!(opt & (1<<2))) {
35 /* -r N defaults to -s N */ 46 /* -r N defaults to -s N */
36 tls->ifd = tls->ofd; 47 tls->ifd = tls->ofd;
37 } 48 }
49#else
50 opt = getopt32(argv, "eh:n:", &hstr, &sni);
51#endif
38 52
39 if (!(opt & (3<<1))) { 53 if (!(opt & (3<<1))) {
40 if (!argv[1]) 54 if (!argv[1])
@@ -47,6 +61,13 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv)
47 sni = argv[1]; 61 sni = argv[1];
48 tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443); 62 tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443);
49 } 63 }
64#if ENABLE_PLATFORM_MINGW32
65 else {
66 if (!hstr || sscanf(hstr, "%p", &h) != 1)
67 bb_error_msg_and_die("invalid handle");
68 tls->ifd = tls->ofd = _open_osfhandle((intptr_t)h, _O_RDWR|_O_BINARY);
69 }
70#endif
50 71
51 tls_handshake(tls, sni); 72 tls_handshake(tls, sni);
52 73