surf

Surf web browser.
git clone git://r-36.net/surf
Log | Files | Refs | README | LICENSE

commit f8b5e516c6c2afb914a5077817510e2db2a6cf72
parent 99376fa57fdd6537600ca819a55d18f890c6a45b
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed, 19 Apr 2017 18:22:34 +0200

Add support to toggle strict TLS/SSL on the fly.

Diffstat:
config.def.h | 4+++-
surf.1 | 18++++++++++++------
surf.c | 35+++++++++++++++++++++++++++++++----
3 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -19,7 +19,8 @@ static char *cookiefile = "~/.surf/cookies.txt"; static char *cookiepolicies = "Aa@"; /* A: accept all; a: accept nothing, * @: accept all except third party */ static char *cafile = "/etc/ssl/certs/ca-certificates.crt"; -static Bool strictssl = FALSE; /* Refuse untrusted SSL connections */ +static Bool strictssl = TRUE; /* strict means if to refuse untrusted + * tls/ssl connections */ static time_t sessiontime = 3600; /* Webkit default features */ @@ -123,6 +124,7 @@ static Key keys[] = { { MODKEY|GDK_SHIFT_MASK,GDK_i, toggle, { .v = "auto-load-images" } }, { MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } }, { MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } }, + { MODKEY|GDK_SHIFT_MASK,GDK_t, togglesoup, { .v = "ssl-strict" } }, { MODKEY|GDK_SHIFT_MASK,GDK_a, togglecookiepolicy, { 0 } }, { MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } }, { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } }, diff --git a/surf.1 b/surf.1 @@ -3,12 +3,12 @@ surf \- simple webkit-based browser .SH SYNOPSIS .B surf -.RB [-bBdDfFgGiIkKmMnNpPsSvx] +.RB [-bBdDfFgGiIkKmMnNpPsStTvx] .RB [-a\ cookiepolicies] .RB [-c\ cookiefile] .RB [-e\ xid] .RB [-r\ scriptfile] -.RB [-t\ stylefile] +.RB [-y\ stylefile] .RB [-u\ useragent] .RB [-z\ zoomlevel] .RB "URI" @@ -102,10 +102,11 @@ Disable Javascript .B \-S Enable Javascript .TP -.B \-t stylefile -Specify the user -.I stylefile. -This does disable the site-specific styles. +.B \-t +Disable strict SSL/TLS checking. +.TP +.B \-T +Enable strict SSL/TLS checking. .TP .B \-u useragent Specify the @@ -118,6 +119,11 @@ Prints version information to standard output, then exits. .B \-x Prints xid to standard output. This can be used to script the browser in for example +.TP +.B \-y stylefile +Specify the user +.I stylefile. +This does disable the site-specific styles. .BR xdotool(1). .TP .B \-z zoomlevel diff --git a/surf.c b/surf.c @@ -104,7 +104,7 @@ static GdkNativeWindow embed = 0; static gboolean showxid = FALSE; static char winid[64]; static gboolean usingproxy = 0; -static char togglestat[9]; +static char togglestat[10]; static char pagestat[3]; static GTlsDatabase *tlsdb; static int policysel = 0; @@ -211,6 +211,7 @@ static void togglecookiepolicy(Client *c, const Arg *arg); static void togglegeolocation(Client *c, const Arg *arg); static void toggleproxy(Client *c, const Arg *arg); static void togglescrollbars(Client *c, const Arg *arg); +static void togglesoup(Client *c, const Arg *arg); static void togglestyle(Client *c, const Arg *arg); static void updatetitle(Client *c); static void updatewinid(Client *c); @@ -1555,6 +1556,22 @@ togglegeolocation(Client *c, const Arg *arg) } void +togglesoup(Client *c, const Arg *arg) +{ + SoupSession *s; + char *name = (char *)arg->v; + gboolean value; + Arg a = { .b = FALSE }; + + /* request handler */ + s = webkit_get_default_session(); + g_object_get(G_OBJECT(s), name, &value, NULL); + g_object_set(G_OBJECT(s), name, !value, NULL); + + reload(c, &a); +} + +void twitch(Client *c, const Arg *arg) { GtkAdjustment *a; @@ -1584,7 +1601,7 @@ toggleproxy(Client *c, const Arg *arg) if (usingproxy) { pr = NULL; - g_object_get(G_OBJECT(s), "proxy-resolver", &pr); + g_object_get(G_OBJECT(s), "proxy-resolver", &pr, NULL); if (pr != NULL) g_object_unref(pr); @@ -1636,6 +1653,7 @@ gettogglestat(Client *c) gboolean value; int p = 0; WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); + SoupSession *s = webkit_get_default_session(); togglestat[p++] = cookiepolicy_set(cookiepolicy_get()); @@ -1653,6 +1671,9 @@ gettogglestat(Client *c) g_object_get(G_OBJECT(settings), "enable-scripts", &value, NULL); togglestat[p++] = value? 'S': 's'; + g_object_get(G_OBJECT(s), "ssl-strict", &value, NULL); + togglestat[p++] = value? 'T': 't'; + g_object_get(G_OBJECT(settings), "enable-plugins", &value, NULL); togglestat[p++] = value? 'V': 'v'; @@ -1714,8 +1735,8 @@ updatewinid(Client *c) void usage(void) { - die("usage: %s [-bBdDfFgGiIkKmMnNpPsSvx] [-a cookiepolicies ] " - "[-c cookiefile] [-e xid] [-r scriptfile] [-t stylefile] " + die("usage: %s [-bBdDfFgGiIkKmMnNpPsStTvx] [-a cookiepolicies ] " + "[-c cookiefile] [-e xid] [-r scriptfile] [-y stylefile] " "[-u useragent] [-z zoomlevel] [uri]\n", basename(argv0)); } @@ -1826,6 +1847,12 @@ main(int argc, char *argv[]) enablescripts = 1; break; case 't': + strictssl = 0; + break; + case 'T': + strictssl = 1; + break; + case 'y': stylefile = EARGF(usage()); break; case 'u':