surf-0.4.1-ssl.diff (2888B)
1 diff -r 71388899ac09 config.def.h 2 --- a/config.def.h Tue Jun 08 09:06:10 2010 +0200 3 +++ b/config.def.h Mon Sep 26 22:28:36 2011 +0100 4 @@ -1,11 +1,14 @@ 5 /* modifier 0 means no modifier */ 6 static char *useragent = "Surf/"VERSION" (X11; U; Unix; en-US) AppleWebKit/531.2+ Compatible (Safari)"; 7 -static char *progress = "#FF0000"; 8 +static char *progress = "#0066FF"; 9 +static char *progress_untrust = "#FF0000"; 10 static char *progress_trust = "#00FF00"; 11 static char *stylefile = ".surf/style.css"; 12 static char *scriptfile = ".surf/script.js"; 13 static char *cookiefile = ".surf/cookies.txt"; 14 static time_t sessiontime = 3600; 15 +static char *cafile = "/etc/ssl/certs/ca-certificates.crt"; 16 +static char *strictssl = FALSE; 17 #define NOBACKGROUND 0 18 19 #define SETPROP(p, q) { .v = (char *[]){ "/bin/sh", "-c", \ 20 diff -r 71388899ac09 surf.c 21 --- a/surf.c Tue Jun 08 09:06:10 2010 +0200 22 +++ b/surf.c Mon Sep 26 22:28:36 2011 +0100 23 @@ -38,6 +38,7 @@ 24 char *title, *linkhover; 25 const char *uri, *needle; 26 gint progress; 27 + gboolean sslfailed; 28 struct Client *next; 29 gboolean zoomed; 30 } Client; 31 @@ -250,8 +251,11 @@ 32 w = c->indicator; 33 width = c->progress * w->allocation.width / 100; 34 gc = gdk_gc_new(w->window); 35 - gdk_color_parse(strstr(uri, "https://") == uri ? 36 - progress_trust : progress, &fg); 37 + if(strstr(uri, "https://") == uri) 38 + gdk_color_parse(c->sslfailed ? 39 + progress_untrust : progress_trust, &fg); 40 + else 41 + gdk_color_parse(progress, &fg); 42 gdk_gc_set_rgb_fg_color(gc, &fg); 43 gdk_draw_rectangle(w->window, 44 w->style->bg_gc[GTK_WIDGET_STATE(w)], 45 @@ -367,9 +371,24 @@ 46 47 void 48 loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) { 49 + WebKitWebFrame *frame; 50 + WebKitWebDataSource *src; 51 + WebKitNetworkRequest *request; 52 + SoupMessage *msg; 53 + char *uri; 54 + 55 switch(webkit_web_view_get_load_status (c->view)) { 56 case WEBKIT_LOAD_COMMITTED: 57 - setatom(c, AtomUri, geturi(c)); 58 + uri = geturi(c); 59 + if(strstr(uri, "https://") == uri) { 60 + frame = webkit_web_view_get_main_frame(c->view); 61 + src = webkit_web_frame_get_data_source(frame); 62 + request = webkit_web_data_source_get_request(src); 63 + msg = webkit_network_request_get_message(request); 64 + c->sslfailed = soup_message_get_flags(msg) 65 + ^ SOUP_MESSAGE_CERTIFICATE_TRUSTED; 66 + } 67 + setatom(c, AtomUri, uri); 68 break; 69 case WEBKIT_LOAD_FINISHED: 70 c->progress = 0; 71 @@ -698,6 +717,10 @@ 72 soup_session_remove_feature_by_type(s, soup_cookie_jar_get_type()); 73 g_signal_connect_after(G_OBJECT(s), "request-started", G_CALLBACK(newrequest), NULL); 74 75 + /* ssl */ 76 + g_object_set(G_OBJECT(s), "ssl-ca-file", cafile, NULL); 77 + g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL); 78 + 79 /* proxy */ 80 if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { 81 new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) :