Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Index: network-openssl.c
===================================================================
--- network-openssl.c (revision 5224)
+++ network-openssl.c (working copy)
@@ -50,6 +50,19 @@
int port;
} GIOSSLChannel;
+void irssi_redraw(void);
+
+static int getpass_cb(char *buf, int size, int rwflag, void *keyname)
+{
+ char *pp, prompt[256];
+ snprintf(prompt, 256, "Enter Passphrase for %s:", keyname);
+ pp = getpass(prompt);
+ strncpy(buf, pp, size);
+ buf[size - 1] = '\0';
+ irssi_redraw();
+ return(strlen(buf));
+}
+
static int ssl_inited = FALSE;
static void irssi_ssl_free(GIOChannel *handle)
@@ -463,6 +476,8 @@
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment