diff --git a/examples/tun/tun.c b/examples/tun/tun.c
index f62ac6586f778d6b84474ead4a3c5054a83f76ce..700f59bc8ab4ee517e5f295d34c42cce7cca02f4 100644
--- a/examples/tun/tun.c
+++ b/examples/tun/tun.c
@@ -2,7 +2,8 @@
 
 static const char *s_local_port = ":8001";
 static const char *s_dispatcher = "ws://localhost:8000";
-static const char *s_auth = "foo:bar";
+static const char *s_user = "foo";
+static const char *s_pass = "bar";
 
 void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
   struct http_message *hm = (struct http_message *) ev_data;
@@ -36,16 +37,19 @@ int main(int argc, char **argv) {
   for (i = 1; i < argc; i++) {
     if (strcmp(argv[i], "-D") == 0) {
       mgr.hexdump_file = argv[++i];
-    } else if (strcmp(argv[i], "-p") == 0) {
+    } else if (strcmp(argv[i], "-l") == 0) {
       s_local_port = argv[++i];
     } else if (strcmp(argv[i], "-d") == 0) {
       s_dispatcher = argv[++i];
     } else if (strcmp(argv[i], "-u") == 0) {
-      s_auth = argv[++i];
+      s_user = argv[++i];
+    } else if (strcmp(argv[i], "-p") == 0) {
+      s_pass = argv[++i];
     }
   }
 
-  if ((nc = mg_tuna_bind(&mgr, ev_handler, s_dispatcher, s_auth)) == NULL) {
+  if ((nc = mg_tuna_bind(&mgr, ev_handler, s_dispatcher, s_user, s_pass)) ==
+      NULL) {
     fprintf(stderr, "Cannot create tunneled listening socket on [%s]\n",
             s_dispatcher);
     exit(EXIT_FAILURE);
diff --git a/mongoose.c b/mongoose.c
index b2cacea30419f58fdb1559e909b2bd6dc7e310da..d14edbce301e0e04a30d13a56c368616b10bdfd0 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -10557,11 +10557,12 @@ static void mg_tun_reconnect(struct mg_tun_client *client);
 
 static void mg_tun_init_client(struct mg_tun_client *client, struct mg_mgr *mgr,
                                struct mg_iface *iface, const char *dispatcher,
-                               const char *auth) {
+                               const char *user, const char *pass) {
   client->mgr = mgr;
   client->iface = iface;
   client->disp_url = dispatcher;
-  client->auth = auth;
+  client->user = user;
+  client->pass = pass;
   client->last_stream_id = 0;
 
   client->disp = NULL;     /* will be set by mg_tun_reconnect */
@@ -10671,7 +10672,7 @@ static void mg_tun_do_reconnect(struct mg_tun_client *client) {
   mbuf_init(&headers, 0);
 
   /* HTTP/Websocket listener */
-  mg_basic_auth_header(client->auth, NULL, &headers);
+  mg_basic_auth_header(client->user, client->pass, &headers);
   mbuf_append(&headers, "", 1); /* nul terminate */
   if ((dc = mg_connect_ws(client->mgr, mg_tun_client_handler, client->disp_url,
                           "mg_tun", headers.buf)) == NULL) {
@@ -10709,7 +10710,8 @@ static void mg_tun_reconnect(struct mg_tun_client *client) {
 
 static struct mg_tun_client *mg_tun_create_client(struct mg_mgr *mgr,
                                                   const char *dispatcher,
-                                                  const char *auth) {
+                                                  const char *user,
+                                                  const char *pass) {
   struct mg_tun_client *client = NULL;
   struct mg_iface *iface = mg_find_iface(mgr, &mg_tun_iface_vtable, NULL);
   if (iface == NULL) {
@@ -10719,7 +10721,7 @@ static struct mg_tun_client *mg_tun_create_client(struct mg_mgr *mgr,
   }
 
   client = (struct mg_tun_client *) MG_MALLOC(sizeof(*client));
-  mg_tun_init_client(client, mgr, iface, dispatcher, auth);
+  mg_tun_init_client(client, mgr, iface, dispatcher, user, pass);
   iface->data = client;
 
   mg_tun_do_reconnect(client);
@@ -10744,8 +10746,10 @@ static struct mg_connection *mg_tuna_do_bind(struct mg_tun_client *client,
 
 struct mg_connection *mg_tuna_bind(struct mg_mgr *mgr,
                                    mg_event_handler_t handler,
-                                   const char *dispatcher, const char *auth) {
-  struct mg_tun_client *client = mg_tun_create_client(mgr, dispatcher, auth);
+                                   const char *dispatcher, const char *user,
+                                   const char *pass) {
+  struct mg_tun_client *client =
+      mg_tun_create_client(mgr, dispatcher, user, pass);
   if (client == NULL) {
     return NULL;
   }
diff --git a/mongoose.h b/mongoose.h
index 14ae49768ff47a91216c868668ea75b516eab3bf..f0022b45c44b9a821031ffbb7bddd1fc7de606aa 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -5560,7 +5560,9 @@ struct mg_tun_client {
   struct mg_mgr *mgr;
   struct mg_iface *iface;
   const char *disp_url;
-  const char *auth;
+  const char *user;
+  const char *pass;
+
   uint32_t last_stream_id; /* stream id of most recently accepted connection */
 
   struct mg_connection *disp;
@@ -5573,7 +5575,8 @@ extern "C" {
 
 struct mg_connection *mg_tuna_bind(struct mg_mgr *mgr,
                                    mg_event_handler_t handler,
-                                   const char *dispatcher, const char *auth);
+                                   const char *dispatcher, const char *user,
+                                   const char *pass);
 
 int mg_tun_parse_frame(void *data, size_t len, struct mg_tun_frame *frame);