if you connect to the test server using a browser at the
same time you will be able to see the circles being drawn.
+The test client supports SSL too, use
+
+```bash
+$ libwebsockets-test-client localhost --ssl -s
+```
+
+the -s tells it to accept the default selfsigned cert from the server,
+otherwise it will strictly fail the connection if there is no CA cert to
+validate the server's certificate.
+
Testing simple echo
-------------------
* past here, we can't simply free the structs as error
* handling as oom4 does. We have to run the whole close flow.
*/
+ if (!wsi->protocol)
+ wsi->protocol = &wsi->context->protocols[0];
+
wsi->protocol->callback(wsi, LWS_CALLBACK_WSI_CREATE,
wsi->user_space, NULL, 0);
lws_set_timeout(wsi,
if (n != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
n, ERR_error_string(n, sb));
- return 0;
+ goto bail3;
}
}
} else
if (n != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
n, ERR_error_string(n, sb));
- return 0;
+ goto bail3;
}
}
}
n, ERR_error_string(n, sb));
lws_close_free_wsi(wsi,
LWS_CLOSE_STATUS_NOSTATUS);
- return 0;
+ return -1;
}
}
#endif /* USE_WOLFSSL */
bail3:
lwsl_info("closing conn at LWS_CONNMODE...SERVER_REPLY\n");
+ wsi->context->protocols[0].callback(wsi,
+ LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
+ wsi->user_space, NULL, 0);
+
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
return -1;
* cleanup like flush partials.
*/
wsi->socket_is_permanently_unusable = 1;
+ if (wsi->mode == LWSCM_WSCL_WAITING_SSL)
+ wsi->context->protocols[0].callback(wsi,
+ LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
+ wsi->user_space, NULL, 0);
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
return 1;
if (!strcmp(prot, "http") || !strcmp(prot, "ws"))
use_ssl = 0;
if (!strcmp(prot, "https") || !strcmp(prot, "wss"))
- use_ssl = 1;
+ if (!use_ssl)
+ use_ssl = 1;
+
+ if (use_ssl) {
+ if (use_ssl == 1)
+ lwsl_notice(" Cert must validate correctly (use -s to allow selfsigned)\n");
+ else
+ lwsl_notice(" Selfsigned certs allowed\n");
+ }
/*
* create the websockets context. This tracks open connections and