Add --disable-ssl flag to webrtc-sendrecv.c

This commit is contained in:
maxmcd 2018-06-06 12:51:15 -04:00 committed by Sebastian Dröge
parent 83b9c4efd7
commit b826f968cb
2 changed files with 9 additions and 10 deletions

View file

@ -7,14 +7,12 @@ RUN apt-get install -y libjson-glib-dev
WORKDIR /opt/ WORKDIR /opt/
COPY . /opt/ COPY . /opt/
RUN sed -i 's/wss:\/\/webrtc.nirbheek.in:8443/ws:\/\/signalling:8443/g' \
/opt/webrtc-sendrecv.c
RUN sed -i 's/strict_ssl = TRUE/strict_ssl = FALSE/g' \
/opt/webrtc-sendrecv.c
RUN make RUN make
CMD echo "Waiting a few seconds for you to open the browser at localhost:8080" \ CMD echo "Waiting a few seconds for you to open the browser at localhost:8080" \
&& sleep 10 \ && sleep 10 \
&& ./webrtc-sendrecv --peer-id=1 && ./webrtc-sendrecv \
--peer-id=1 \
--server=ws://signalling:8443 \
--disable-ssl

View file

@ -45,12 +45,13 @@ static SoupWebsocketConnection *ws_conn = NULL;
static enum AppState app_state = 0; static enum AppState app_state = 0;
static const gchar *peer_id = NULL; static const gchar *peer_id = NULL;
static const gchar *server_url = "wss://webrtc.nirbheek.in:8443"; static const gchar *server_url = "wss://webrtc.nirbheek.in:8443";
static gboolean strict_ssl = TRUE; static gboolean disable_ssl = FALSE;
static GOptionEntry entries[] = static GOptionEntry entries[] =
{ {
{ "peer-id", 0, 0, G_OPTION_ARG_STRING, &peer_id, "String ID of the peer to connect to", "ID" }, { "peer-id", 0, 0, G_OPTION_ARG_STRING, &peer_id, "String ID of the peer to connect to", "ID" },
{ "server", 0, 0, G_OPTION_ARG_STRING, &server_url, "Signalling server to connect to", "URL" }, { "server", 0, 0, G_OPTION_ARG_STRING, &server_url, "Signalling server to connect to", "URL" },
{ "disable-ssl", 0, 0, G_OPTION_ARG_NONE, &disable_ssl, "Disable ssl", NULL },
{ NULL }, { NULL },
}; };
@ -569,7 +570,7 @@ connect_to_websocket_server_async (void)
SoupSession *session; SoupSession *session;
const char *https_aliases[] = {"wss", NULL}; const char *https_aliases[] = {"wss", NULL};
session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, strict_ssl, session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT, !disable_ssl,
SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
//SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt", //SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt",
SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL); SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);
@ -634,13 +635,13 @@ main (int argc, char *argv[])
return -1; return -1;
} }
/* Don't use strict ssl when running a localhost server, because /* Disable ssl when running a localhost server, because
* it's probably a test server with a self-signed certificate */ * it's probably a test server with a self-signed certificate */
{ {
GstUri *uri = gst_uri_from_string (server_url); GstUri *uri = gst_uri_from_string (server_url);
if (g_strcmp0 ("localhost", gst_uri_get_host (uri)) == 0 || if (g_strcmp0 ("localhost", gst_uri_get_host (uri)) == 0 ||
g_strcmp0 ("127.0.0.1", gst_uri_get_host (uri)) == 0) g_strcmp0 ("127.0.0.1", gst_uri_get_host (uri)) == 0)
strict_ssl = FALSE; disable_ssl = TRUE;
gst_uri_unref (uri); gst_uri_unref (uri);
} }