From 42f8ef8001e11c640695102b12bcc879a58d69b5 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Thu, 3 Jan 2013 18:04:13 +0000 Subject: [PATCH] Melhorando indicação de status da conexão SSL --- src/include/lib3270.h | 3 ++- src/include/pw3270/v3270.h | 3 ++- src/lib3270/telnet.c | 5 ++++- src/pw3270/colors.c | 24 +++++++++++++++++++++--- src/pw3270/v3270/negotiated.xbm | 14 ++++++++++++++ src/pw3270/v3270/oia.c | 19 ++++++++++++++----- src/pw3270/v3270/unlocked.xbm | 28 ++++++++++++++-------------- src/pw3270/v3270/widget.c | 8 ++++++++ 8 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 src/pw3270/v3270/negotiated.xbm diff --git a/src/include/lib3270.h b/src/include/lib3270.h index 0c7bd18..a38fa5d 100644 --- a/src/include/lib3270.h +++ b/src/include/lib3270.h @@ -267,7 +267,8 @@ typedef enum lib3270_ssl_state { LIB3270_SSL_UNSECURE, /**< No secure connection */ - LIB3270_SSL_SECURE, /**< Connection secure */ + LIB3270_SSL_SECURE, /**< Connection secure with CA check */ + LIB3270_SSL_NEGOTIATED, /**< Connection secure, no CA or self-signed */ LIB3270_SSL_NEGOTIATING, /**< Negotiating SSL */ LIB3270_SSL_UNDEFINED /**< Undefined */ } LIB3270_SSL_STATE; diff --git a/src/include/pw3270/v3270.h b/src/include/pw3270/v3270.h index 5e7812c..718db35 100644 --- a/src/include/pw3270/v3270.h +++ b/src/include/pw3270/v3270.h @@ -84,12 +84,13 @@ V3270_COLOR_OIA_FOREGROUND, V3270_COLOR_OIA_SEPARATOR, V3270_COLOR_OIA_STATUS_OK, + V3270_COLOR_OIA_STATUS_WARNING, V3270_COLOR_OIA_STATUS_INVALID, V3270_COLOR_COUNT }; - #define V3270_COLOR_OIA_STATUS_WARNING V3270_COLOR_OIA_STATUS_OK +// #define V3270_COLOR_OIA_STATUS_WARNING V3270_COLOR_OIA_STATUS_OK typedef enum _v3270_oia_field { diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 1d37c3d..9e7499f 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -861,6 +861,9 @@ static void ssl_negotiate(H3270 *hSession) SSL_get_verify_result(hSession->ssl_con)); } + if(!SSL_get_verify_result(hSession->ssl_con)) + set_ssl_state(hSession,LIB3270_SSL_SECURE); + /* Tell the world that we are (still) connected, now in secure mode. */ lib3270_set_connected(hSession); } @@ -3277,7 +3280,7 @@ static void ssl_info_callback(INFO_CONST SSL *s, int where, int ret) { trace_dsn(hSession,"%s: SSL_CB_HANDSHAKE_DONE state=%04x\n",__FUNCTION__,SSL_state(s)); if(SSL_state(s) == 0x03) - set_ssl_state(hSession,LIB3270_SSL_SECURE); + set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED); else set_ssl_state(hSession,LIB3270_SSL_UNSECURE); } diff --git a/src/pw3270/colors.c b/src/pw3270/colors.c index 8a6dedc..8062ce5 100644 --- a/src/pw3270/colors.c +++ b/src/pw3270/colors.c @@ -126,14 +126,31 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr) clr[V3270_COLOR_OIA_SEPARATOR] = clr[V3270_COLOR_GREEN]; clr[V3270_COLOR_OIA_STATUS_OK] = clr[V3270_COLOR_GREEN]; clr[V3270_COLOR_OIA_STATUS_INVALID] = clr[V3270_COLOR_RED]; + clr[V3270_COLOR_OIA_STATUS_WARNING] = clr[V3270_COLOR_YELLOW]; val = g_key_file_get_string(conf,group,"OIA",NULL); if(val) { - gchar **str = g_strsplit(val,",",5); + gchar **str = g_strsplit(val,",",6); - for(f=0;f< MIN(g_strv_length(str),4); f++) - gdk_color_parse(str[f],clr+V3270_COLOR_OIA_BACKGROUND+f); + // 0 = V3270_COLOR_OIA_BACKGROUND, + // 1 = V3270_COLOR_OIA_FOREGROUND, + // 2 = V3270_COLOR_OIA_SEPARATOR, + // 3 = V3270_COLOR_OIA_STATUS_OK, + // 4 = V3270_COLOR_OIA_STATUS_WARNING, + // 5 = V3270_COLOR_OIA_STATUS_INVALID, + + if(g_strv_length(str) == 5) + { + for(f=0;f < 5; f++) + gdk_color_parse(str[f],clr+V3270_COLOR_OIA_BACKGROUND+f); + clr[V3270_COLOR_OIA_STATUS_INVALID] = clr[V3270_COLOR_OIA_STATUS_WARNING]; + } + else + { + for(f=0;f< MIN(g_strv_length(str),6); f++) + gdk_color_parse(str[f],clr+V3270_COLOR_OIA_BACKGROUND+f); + } g_strfreev(str); } @@ -405,6 +422,7 @@ static void load_color_scheme(GKeyFile *conf, const gchar *group, GdkColor *clr) N_( "OIA foreground" ), // TERMINAL_COLOR_OIA_FOREGROUND N_( "OIA separator" ), // TERMINAL_COLOR_OIA_SEPARATOR N_( "OIA status ok" ), // TERMINAL_COLOR_OIA_STATUS_OK + N_( "OIA Warning" ), // V3270_COLOR_OIA_STATUS_WARNING N_( "OIA status invalid" ), // TERMINAL_COLOR_OIA_STATUS_INVALID }; diff --git a/src/pw3270/v3270/negotiated.xbm b/src/pw3270/v3270/negotiated.xbm new file mode 100644 index 0000000..263ac23 --- /dev/null +++ b/src/pw3270/v3270/negotiated.xbm @@ -0,0 +1,14 @@ +#define negotiated_width 32 +#define negotiated_height 32 +static unsigned char negotiated_bits[] = { + 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x07, 0xe0, 0x00, + 0x80, 0x03, 0xc0, 0x01, 0xc0, 0xf1, 0x8f, 0x03, 0xc0, 0xf8, 0x1f, 0x03, + 0xc0, 0x1c, 0x38, 0x03, 0xc0, 0x0c, 0x30, 0x03, 0xc0, 0x0c, 0x30, 0x03, + 0xc0, 0x0c, 0x30, 0x03, 0xc0, 0x0c, 0x30, 0x03, 0xc0, 0x0c, 0x30, 0x03, + 0xc0, 0x0c, 0x30, 0x03, 0xc0, 0x0c, 0x30, 0x03, 0xf0, 0xff, 0xff, 0x0f, + 0xf0, 0xff, 0xff, 0x0f, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, + 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, + 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, + 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, + 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x0c, + 0xf0, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x0f }; diff --git a/src/pw3270/v3270/oia.c b/src/pw3270/v3270/oia.c index 17b74fb..23e3cf3 100644 --- a/src/pw3270/v3270/oia.c +++ b/src/pw3270/v3270/oia.c @@ -52,6 +52,7 @@ static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_m #include "locked.xbm" #include "unlocked.xbm" + #include "negotiated.xbm" /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -334,8 +335,16 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri bits = (unsigned char *) unlocked_bits; break; - case LIB3270_SSL_SECURE: /**< Connection secure */ - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_FOREGROUND); + case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); + width = negotiated_width; + height = negotiated_height; + bits = (unsigned char *) negotiated_bits; + break; + + + case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); width = locked_width; height = locked_height; bits = (unsigned char *) locked_bits; @@ -343,9 +352,9 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); - width = locked_width; - height = locked_height; - bits = (unsigned char *) locked_bits; + width = unlocked_width; + height = unlocked_height; + bits = (unsigned char *) unlocked_bits; break; default: diff --git a/src/pw3270/v3270/unlocked.xbm b/src/pw3270/v3270/unlocked.xbm index 6dcf3ee..5d7ab13 100644 --- a/src/pw3270/v3270/unlocked.xbm +++ b/src/pw3270/v3270/unlocked.xbm @@ -1,14 +1,14 @@ -#define unlocked_width 32 -#define unlocked_height 32 -static unsigned char unlocked_bits[] = { - 0x00, 0x00, 0xff, 0x0f, 0x00, 0x80, 0xff, 0x1f, 0x00, 0xc0, 0x01, 0x38, - 0x00, 0xe0, 0x00, 0x70, 0x00, 0x70, 0xfc, 0xe3, 0x00, 0x30, 0xfe, 0xc7, - 0x00, 0x30, 0x07, 0xce, 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, - 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, - 0x00, 0x30, 0x03, 0xfc, 0x00, 0x30, 0x03, 0xfc, 0xff, 0xff, 0x3f, 0x00, - 0xff, 0xff, 0x3f, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, - 0xcf, 0xcc, 0x3c, 0x00, 0xcf, 0xcc, 0x3c, 0x00, 0x33, 0x33, 0x33, 0x00, - 0x33, 0x33, 0x33, 0x00, 0xcf, 0xcc, 0x3c, 0x00, 0xcf, 0xcc, 0x3c, 0x00, - 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xcf, 0xcc, 0x3c, 0x00, - 0xcf, 0xcc, 0x3c, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, - 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x3f, 0x00 }; +#define unlocked_width 32 +#define unlocked_height 32 +static unsigned char unlocked_bits[] = { + 0x00, 0x00, 0xff, 0x0f, 0x00, 0x80, 0xff, 0x1f, 0x00, 0xc0, 0x01, 0x38, + 0x00, 0xe0, 0x00, 0x70, 0x00, 0x70, 0xfc, 0xe3, 0x00, 0x30, 0xfe, 0xc7, + 0x00, 0x30, 0x07, 0xce, 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, + 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, 0x00, 0x30, 0x03, 0xcc, + 0x00, 0x30, 0x03, 0xfc, 0x00, 0x30, 0x03, 0xfc, 0xff, 0xff, 0x3f, 0x00, + 0xff, 0xff, 0x3f, 0x00, 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, + 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, + 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, + 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, + 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, 0x03, 0x00, 0x30, 0x00, + 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0x3f, 0x00 }; diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index b0e7961..41f81f8 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -1167,6 +1167,7 @@ void v3270_set_colors(GtkWidget *widget, const gchar *colors) "#00FF00," // V3270_COLOR_OIA "#7890F0," // V3270_COLOR_OIA_SEPARATOR "#FFFFFF," // V3270_COLOR_OIA_STATUS_OK + "#FFFF00," // V3270_COLOR_OIA_STATUS_WARNING "#FF0000"; // V3270_COLOR_OIA_STATUS_INVALID } @@ -1228,8 +1229,15 @@ void v3270_set_color_table(GdkColor *table, const gchar *colors) clr = g_strsplit(colors,",",V3270_COLOR_COUNT+1); cnt = g_strv_length(clr); + switch(cnt) { + case 28: // Version 4 string + for(f=0;f < 28;f++) + gdk_color_parse(clr[f],table+f); + table[V3270_COLOR_OIA_STATUS_INVALID] = table[V3270_COLOR_OIA_STATUS_WARNING]; + break; + case V3270_COLOR_COUNT: // Complete string for(f=0;f < V3270_COLOR_COUNT;f++) gdk_color_parse(clr[f],table+f); -- libgit2 0.21.2