irssi/irssi-0.8.15-ssl-passphrase.patch

34 lines
1.2 KiB
Diff
Raw Normal View History

From: http://bugs.irssi.org/index.php?do=details&task_id=305
-> http://bugs.irssi.org/index.php?getfile=298
Redraw logic removed.
Index: irssi-0.8.15/src/core/network-openssl.c
===================================================================
--- irssi-0.8.15.orig/src/core/network-openssl.c
+++ irssi-0.8.15/src/core/network-openssl.c
@@ -374,6 +374,16 @@ static GIOFuncs irssi_ssl_channel_funcs
irssi_ssl_get_flags
};
+static int getpass_cb(char *buf, int size, int rwflag, void *keyname)
+{
+ char *pp, prompt[256];
+ snprintf(prompt, 256, "Enter PEM pass phrase:"); // for %s:", keyname);
+ pp = getpass(prompt);
+ strncpy(buf, pp, size);
+ buf[size - 1] = '\0';
+ return(strlen(buf));
+}
+
static gboolean irssi_ssl_init(void)
{
SSL_library_init();
@@ -412,6 +422,8 @@ static GIOChannel *irssi_ssl_get_iochann
scert = convert_home(mycert);
if (mypkey && *mypkey)
spkey = convert_home(mypkey);
+ SSL_CTX_set_default_passwd_cb(ctx, getpass_cb);
+ SSL_CTX_set_default_passwd_cb_userdata(ctx, spkey);
if (! SSL_CTX_use_certificate_file(ctx, scert, SSL_FILETYPE_PEM))
g_warning("Loading of client certificate '%s' failed", mycert);
else if (! SSL_CTX_use_PrivateKey_file(ctx, spkey ? spkey : scert, SSL_FILETYPE_PEM))