File xchat-ssl.patch of Package xchat

---
 src/common/server.c     |   16 +++++++++++
 src/fe-gtk/Makefile.am  |    2 -
 src/fe-gtk/fe-gtk.h     |    3 ++
 src/fe-gtk/passphrase.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/fe-gtk/passphrase.h |    3 ++
 5 files changed, 92 insertions(+), 1 deletion(-)

Index: xchat-2.8.6/src/common/server.c
===================================================================
--- xchat-2.8.6.orig/src/common/server.c
+++ xchat-2.8.6/src/common/server.c
@@ -60,6 +60,7 @@
 #include <openssl/ssl.h>		  /* SSL_() */
 #include <openssl/err.h>		  /* ERR_() */
 #include "ssl.h"
+#include "../fe-gtk/passphrase.h"
 #endif
 
 #ifdef USE_MSPROXY
@@ -84,6 +85,18 @@ static void server_disconnect (session *
 static int server_cleanup (server * serv);
 static void server_connect (server *serv, char *hostname, int port, int no_login);
 
+#ifdef USE_OPENSSL
+static int
+pem_passwd_cb (char *buf, int size, int rwflag, void *userdata)
+{
+   char *passwd = NULL;
+   server *serv = userdata;
+   passwd = passphrase_dialog(serv);
+   if (passwd) { strncpy(buf, passwd, size);
+   buf[size - 1] = '\0';
+   return (strlen(buf)); } else return 0;
+}
+#endif
 
 /* actually send to the socket. This might do a character translation or
    send via SSL. server/dcc both use this function. */
@@ -1666,6 +1679,9 @@ server_connect (server *serv, char *host
 	{
 		char cert_file[256];
 
+		SSL_CTX_set_default_passwd_cb(ctx, pem_passwd_cb);
+		SSL_CTX_set_default_passwd_cb_userdata(ctx, serv);
+
 		/* first try network specific cert/key */
 		snprintf (cert_file, sizeof (cert_file), "%s/%s.pem",
 					 get_xdir_fs (), server_get_network (serv, TRUE));
Index: xchat-2.8.6/src/fe-gtk/Makefile.am
===================================================================
--- xchat-2.8.6.orig/src/fe-gtk/Makefile.am
+++ xchat-2.8.6/src/fe-gtk/Makefile.am
@@ -29,4 +29,4 @@ xchat_SOURCES = about.c ascii.c banlist.
 	dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \
 	maingui.c $(mmx_cmod_S) notifygui.c palette.c pixmaps.c plugin-tray.c $(plugingui_c) \
 	rawlog.c search.c servlistgui.c setup.c $(sexy_spell_entry_c) textgui.c \
-	urlgrab.c userlistgui.c xtext.c
+	urlgrab.c userlistgui.c xtext.c passphrase.c
Index: xchat-2.8.6/src/fe-gtk/fe-gtk.h
===================================================================
--- xchat-2.8.6.orig/src/fe-gtk/fe-gtk.h
+++ xchat-2.8.6/src/fe-gtk/fe-gtk.h
@@ -52,6 +52,9 @@ struct server_gui
 	GtkWidget *rawlog_window;
 	GtkWidget *rawlog_textlist;
 
+	/* passphrase dialog */
+	GtkWidget *passphrase_win;
+
 	/* join dialog */
 	GtkWidget *joind_win;
 	GtkWidget *joind_entry;
Index: xchat-2.8.6/src/fe-gtk/passphrase.c
===================================================================
--- /dev/null
+++ xchat-2.8.6/src/fe-gtk/passphrase.c
@@ -0,0 +1,69 @@
+/* X-Chat
+ * Passphrase dialog
+ * Copyright (C) 2006 Wolfgang Rosenauer.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <gtk/gtk.h>
+#include "../common/xchat.h"
+#include "../common/xchatc.h"
+#include "../common/server.h"
+#include "fe-gtk.h"
+
+
+static void 
+accept_passphrase_cb (GtkWidget *IGNORED, GtkDialog *dialog) 
+{
+   gtk_dialog_response (dialog, GTK_RESPONSE_ACCEPT);
+}
+
+
+char *
+passphrase_dialog (server *serv)
+{
+    GtkWidget *dialog;
+    GtkWidget *entry;
+    char *res = NULL;
+    
+    serv->gui->passphrase_win = dialog = gtk_dialog_new_with_buttons(
+                                         "Passphrase",
+                                         NULL,
+                                         GTK_DIALOG_NO_SEPARATOR,
+                                         GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+                                         NULL);
+    
+    gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
+    gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+    /* passphrase field */
+    entry = gtk_entry_new();
+    gtk_entry_set_max_length (GTK_ENTRY(entry), 255);
+    gtk_entry_set_visibility (GTK_ENTRY(entry), FALSE);
+    gtk_signal_connect(GTK_OBJECT(entry), "activate", 
+	               G_CALLBACK(accept_passphrase_cb), 
+		       dialog);
+   
+    /* show all */
+    gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), entry);
+    gtk_widget_show_all (dialog);
+
+    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+          res = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+    gtk_widget_destroy (dialog);
+    serv->gui->passphrase_win = NULL;
+    return res;
+}
Index: xchat-2.8.6/src/fe-gtk/passphrase.h
===================================================================
--- /dev/null
+++ xchat-2.8.6/src/fe-gtk/passphrase.h
@@ -0,0 +1,3 @@
+
+
+char *passphrase_dialog (server *serv);
openSUSE Build Service is sponsored by