diff options
Diffstat (limited to 'networking/ssl_client.c')
-rw-r--r-- | networking/ssl_client.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/networking/ssl_client.c b/networking/ssl_client.c index 582fb0e71..757745896 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,23 @@ 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(); |
42 | #if !ENABLE_PLATFORM_MINGW32 | ||
33 | opt = getopt32(argv, "es:+r:+n:", &tls->ofd, &tls->ifd, &sni); | 43 | opt = getopt32(argv, "es:+r:+n:", &tls->ofd, &tls->ifd, &sni); |
34 | if (!(opt & (1<<2))) { | 44 | if (!(opt & (1<<2))) { |
35 | /* -r N defaults to -s N */ | 45 | /* -r N defaults to -s N */ |
36 | tls->ifd = tls->ofd; | 46 | tls->ifd = tls->ofd; |
37 | } | 47 | } |
48 | #else | ||
49 | opt = getopt32(argv, "eh:n:", &hstr, &sni); | ||
50 | #endif | ||
38 | 51 | ||
39 | if (!(opt & (3<<1))) { | 52 | if (!(opt & (3<<1))) { |
40 | if (!argv[1]) | 53 | if (!argv[1]) |
@@ -47,6 +60,14 @@ int ssl_client_main(int argc UNUSED_PARAM, char **argv) | |||
47 | sni = argv[1]; | 60 | sni = argv[1]; |
48 | tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443); | 61 | tls->ifd = tls->ofd = create_and_connect_stream_or_die(argv[1], 443); |
49 | } | 62 | } |
63 | #if ENABLE_PLATFORM_MINGW32 | ||
64 | else { | ||
65 | if (!hstr || sscanf(hstr, "%p", &h) != 1) | ||
66 | bb_error_msg_and_die("invalid handle"); | ||
67 | init_winsock(); | ||
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 | ||