diff --git a/toys/pending/wget.c b/toys/pending/wget.c
index 5c85889a..c2233c94 100644
--- a/toys/pending/wget.c
+++ b/toys/pending/wget.c
@@ -8,21 +8,39 @@ USE_WGET(NEWTOY(wget, "(no-check-certificate)O:", TOYFLAG_USR|TOYFLAG_BIN))
 config WGET
   bool "wget"
   default n
+  depends on FTPGET
   help
     usage: wget -O filename URL
     -O filename: specify output filename
-    URL: uniform resource location, FTP/HTTP only, not HTTPS
+    URL: uniform resource location, FTP/HTTP/HTTPS
 
     examples:
       wget -O index.html http://www.example.com
       wget -O sample.jpg ftp://ftp.example.com:21/sample.jpg
+
+config WGET_TLS
+  bool "Enable HTTPS support for wget"
+  default n
+  depends on WGET
+  help
+    Enable HTTPS support for wget by linking to libtls.
+    Supports using either libressl-libtls or libtls-bearssl.
 */
 
 #define FOR_wget
 #include "toys.h"
 
+#ifdef CFG_WGET_TLS
+#include <tls.h>
+#endif
+
+#define WGET_FTP   0
+#define WGET_HTTP  1
+#define WGET_HTTPS 2
+
 GLOBALS(
   char *filename;
+  int protocol;
 )
 
 // extract hostname and port from url
@@ -54,7 +72,7 @@ static unsigned get_port(const char *url, char *port, unsigned url_i) {
 static void strip_v6_brackets(char* hostname) {
   size_t len = strlen(hostname);
   if (len > 1023) {
-    error_exit("hostname too long, %d bytes\n", len);
+    error_exit("hostname too long, %zu bytes\n", len);
   }
   char * closing_bracket = strchr(hostname, ']');
   if (closing_bracket && closing_bracket == hostname + len - 1) {
@@ -67,11 +85,22 @@ static void strip_v6_brackets(char* hostname) {
 
 // get http infos in URL
 static void get_info(const char *url, char* hostname, char *port, char *path) {
-  unsigned i = 7, len;
+  unsigned i, len;
   char ftp = !strncmp(url, "ftp://", 6);
 
-  if (ftp) i--;
-  else if (strncmp(url, "http://", i)) error_exit("only FTP/HTTP support");
+  if (ftp) {
+    TT.protocol = WGET_FTP;
+    i = 6;
+  } else if (strncmp(url, "http://", 7) == 0) {
+    TT.protocol = WGET_HTTP;
+    i = 7;
+  }else if (strncmp(url, "https://", 8) == 0) {
+    TT.protocol = WGET_HTTPS;
+    i = 8;
+  } else {
+    error_exit("only FTP/HTTP support");
+  }
+
   len = get_hn(url+i, hostname);
   i += len;
 
@@ -94,7 +123,10 @@ static void get_info(const char *url, char* hostname, char *port, char *path) {
   }
 
   if (use_default_port) {
-    strcpy(port, "80");
+    if (TT.protocol == WGET_HTTPS)
+      strcpy(port, "443");
+    else 
+      strcpy(port, "80");
   }
 
   // This is a NOP if hostname is not a bracketed IPv6 address
@@ -106,8 +138,6 @@ static void get_info(const char *url, char* hostname, char *port, char *path) {
     if (strlen(url+i) < 1024) strcpy(path, url+i);
     else error_exit("too long path in URL");
   } else error_exit("wrong URL");
-
-  if (ftp) xexec((char *[]){"ftpget", hostname, TT.filename, path, 0});
 }
 
 // connect to any IPv4 or IPv6 server
@@ -169,15 +199,39 @@ void wget_main(void)
   char *body, *result, *rc, *r_str, *redir_loc = 0;
   char ua[] = "toybox wget/" TOYBOX_VERSION, hostname[1024], port[6], path[1024];
 
-  // TODO extract filename to be saved from URL
-  if (!(toys.optflags & FLAG_O)) help_exit("no filename");
-  if (fopen(TT.filename, "r")) error_exit("'%s' already exists", TT.filename);
+  #ifdef CFG_WGET_TLS
+    struct tls *ctx = NULL;
+    struct tls_config *cfg = NULL;
+    uint32_t protocols;
+  #endif
 
   if(!toys.optargs[0]) help_exit("no URL");
   get_info(toys.optargs[0], hostname, port, path);
 
+  if (TT.filename == NULL) {
+    TT.filename = strrchr(path, '/');
+    if (TT.filename != NULL) TT.filename++;
+    if (!*TT.filename) TT.filename = "index.html";
+  }
+
+  if (fopen(TT.filename, "r")) error_exit("'%s' already exists", TT.filename);
+
+  if (TT.protocol == WGET_FTP) 
+    xexec((char *[]){"ftpget", hostname, TT.filename, path, 0});
+
+  #ifdef CFG_WGET_TLS
+    if (TT.protocol == WGET_HTTPS) {
+      if ((ctx = tls_client()) == NULL) error_exit("TLSClient init failed.");
+      if ((cfg = tls_config_new()) == NULL) error_exit("TLSConfig init failed.");
+      if (tls_config_parse_protocols(&protocols, "tlsv1.1,tlsv1.2") != 0) error_exit("TLS failed to parse protocols.");
+      if (tls_config_set_protocols(cfg, protocols) != 0) error_exit("TLS failed to set protocols.");
+      if (tls_configure(ctx, cfg) != 0) error_exit("TLS failed to set configuration.");
+    }
+  #else
+    if (TT.protocol == WGET_HTTPS) error_exit("TLS not enabled.");
+  #endif
+
   for (;; redirects--) {
-    sock = conn_svr(hostname, port);
     // compose HTTP request
     sprintf(toybuf, "GET %s HTTP/1.1\r\n", path);
     mk_fld("Host", hostname);
@@ -187,10 +241,26 @@ void wget_main(void)
 
     // send the HTTP request
     len = strlen(toybuf);
-    if (write(sock, toybuf, len) != len) perror_exit("write error");
 
-    // read HTTP response
-    if ((len = read(sock, toybuf, 4096)) == -1) perror_exit("read error");
+    if (TT.protocol == WGET_HTTP) {
+      sock = conn_svr(hostname, port);
+      if (write(sock, toybuf, len) != len) perror_exit("write error");
+
+      // Read HTTP response
+      if ((len = read(sock, toybuf, sizeof(toybuf))) == -1) perror_exit("read error");
+    }
+
+    #ifdef CFG_WGET_TLS
+      if (TT.protocol == WGET_HTTPS) {
+        if (tls_connect(ctx, hostname, port) != 0) perror_exit("connect error");
+        if(tls_write(ctx, toybuf, len) != len) perror_exit("write error");
+
+        // Read HTTP response
+        if ((len = tls_read(ctx, toybuf, sizeof(toybuf))) == -1) perror_exit("read error");
+      }
+    #endif
+
+    // Parse HTTP response
     if (!strstr(toybuf, "\r\n\r\n")) error_exit("too long HTTP response");
     body = get_body(len, &body_len);
     redir_loc = strstr(toybuf, "Location: ");
@@ -215,12 +285,21 @@ void wget_main(void)
     else error_exit("res: %s(%s)", rc, r_str);
   }
 
-
   if (!(fp = fopen(TT.filename, "w"))) perror_exit("fopen error");
   if (fwrite(body, 1, body_len, fp) != body_len)
     error_exit("fwrite error");
-  while ((len = read(sock, toybuf, 4096)) > 0)
-    if (fwrite(toybuf, 1, len, fp) != len)
-      error_exit("fwrite error");
+
+  if (TT.protocol == WGET_HTTP) {
+    while ((len = read(sock, toybuf, sizeof(toybuf))) > 0)
+      if (fwrite(toybuf, 1, len, fp) != len) error_exit("fwrite error");
+  }
+
+  #ifdef CFG_WGET_TLS
+    if (TT.protocol == WGET_HTTPS) {
+      while ((len = tls_read(ctx, toybuf, sizeof(toybuf))) > 0)
+        if (fwrite(toybuf, 1, len, fp) != len) error_exit("fwrite error");
+    }
+  #endif
+
   if (fclose(fp) == EOF) perror_exit("fclose error");
 }
