summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compose.c6
-rw-r--r--contrib/smime.rc6
-rw-r--r--init.h10
-rw-r--r--mutt.h1
-rw-r--r--sendlib.c4
-rw-r--r--smime.c34
-rw-r--r--smime.h2
7 files changed, 45 insertions, 18 deletions
diff --git a/compose.c b/compose.c
index 9ec18e2c..f552faff 100644
--- a/compose.c
+++ b/compose.c
@@ -153,7 +153,7 @@ static void redraw_crypt_lines (HEADER *msg)
#endif
#ifdef HAVE_SMIME
if (msg->security & APPLICATION_SMIME && msg->security & SIGN) {
- printw ("%s%s", _(" sign as: "), SmimeSignAs ? SmimeSignAs : _("<default>"));
+ printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
}
if (msg->security & APPLICATION_SMIME && (msg->security & ENCRYPT)) {
mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
@@ -262,7 +262,7 @@ static int smime_send_menu (HEADER *msg, int *redraw)
case 3: /* (s)ign */
- if(!SmimeSignAs)
+ if(!SmimeDefaultKey)
mutt_message("Can\'t sign: No key specified. use sign(as).");
else
msg->security |= SMIMESIGN;
@@ -272,7 +272,7 @@ static int smime_send_menu (HEADER *msg, int *redraw)
if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) {
p[mutt_strlen (p)-1] = '\0';
- mutt_str_replace (&SmimeSignAs, p);
+ mutt_str_replace (&SmimeDefaultKey, p);
msg->security |= SMIMESIGN;
diff --git a/contrib/smime.rc b/contrib/smime.rc
index 0aacbd09..635496b8 100644
--- a/contrib/smime.rc
+++ b/contrib/smime.rc
@@ -23,7 +23,11 @@ set crypt_verify_sig = yes
# The (default) keyfile for signing/decrypting. Uncomment the following
# line and replace the keyid with your own.
-#set smime_sign_as="12345678.0"
+set smime_default_key="12345678.0"
+
+# Uncommen to make mutt ask what key to use when trying to decrypt a message.
+# It will use the default key above (if that was set) else.
+# unset smime_decrypt_use_default_key
# Path to a file or directory with trusted certificates
set smime_ca_location="~/.smime/ca-bundle.crt"
diff --git a/init.h b/init.h
index 9056630b..fdf47b31 100644
--- a/init.h
+++ b/init.h
@@ -1284,6 +1284,13 @@ struct option_t MuttVars[] = {
** This flag controls wether you want to be asked to enter a label for a certificate
** about to be added to the database or not. It is set by default.
*/
+ { "smime_decrypt_use_default_key", DT_BOOL, R_NONE, OPTSDEFAULTDECRYPTKEY, 1 },
+ /*
+ ** .pp
+ ** If set (default) this tells mutt to use the default key for decryption. Otherwise,
+ ** if manage multiple certificate-key-pairs, mutt will try to use the mailbox-address
+ ** to determine the key to use. It will ask you to supply a key, if it can't find one.
+ */
#endif
#ifdef HAVE_PGP
{ "pgp_entry_format", DT_STR, R_NONE, UL &PgpEntryFormat, UL "%4n %t%f %4l/0x%k %-4a %2c %u" },
@@ -1624,7 +1631,8 @@ struct option_t MuttVars[] = {
** X509 certificates, and for verification purposes (to check, wether the
** certifacate was issued for the sender's mailbox).
*/
- { "smime_sign_as", DT_STR, R_NONE, UL &SmimeSignAs, 0 },
+ { "smime_sign_as", DT_SYN, R_NONE, UL "smime_default_key", 0 },
+ { "smime_default_key", DT_STR, R_NONE, UL &SmimeDefaultKey, 0 },
/*
** .pp
** This is the default key-pair to use vor signing. This must be set to the
diff --git a/mutt.h b/mutt.h
index 59285227..6659bcb0 100644
--- a/mutt.h
+++ b/mutt.h
@@ -430,6 +430,7 @@ enum
#ifdef HAVE_SMIME
OPTSMIMEISDEFAULT,
OPTASKCERTLABEL,
+ OPTSDEFAULTDECRYPTKEY,
#endif
#ifdef HAVE_PGP
OPTPGPIGNORESUB,
diff --git a/sendlib.c b/sendlib.c
index ec816ecd..2c36cc58 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -2406,8 +2406,8 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
}
if (hdr->security & SIGN) {
fputc ('S', msg->fp);
- if (SmimeSignAs && *SmimeSignAs)
- fprintf (msg->fp, "<%s>", SmimeSignAs);
+ if (SmimeDefaultKey && *SmimeDefaultKey)
+ fprintf (msg->fp, "<%s>", SmimeDefaultKey);
}
fputc ('\n', msg->fp);
}
diff --git a/smime.c b/smime.c
index 416044c1..422741f5 100644
--- a/smime.c
+++ b/smime.c
@@ -608,6 +608,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, short m
key = safe_calloc(1, mutt_strlen(fields[1])+2);
if (public) key_trust_level = *fields[4];
snprintf(key, mutt_strlen(fields[1])+1, "%s", fields[1]);
+
}
found = 1;
}
@@ -694,14 +695,16 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, short m
/*
This sets the '*ToUse' variables for an upcoming decryption, where
- the reuquired key is different from SmimeSignAs.
+ the reuquired key is different from SmimeDefaultKey.
*/
void _smime_getkeys (char *mailbox)
{
- char *k = smime_get_field_from_db (mailbox, NULL, 0, 1);
+ char *k = NULL;
char buf[STRING];
+ k = smime_get_field_from_db (mailbox, NULL, 0, 1);
+
if (!k)
{
snprintf(buf, sizeof(buf), _("Enter keyID for %s: "),
@@ -728,7 +731,7 @@ void _smime_getkeys (char *mailbox)
snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
NONULL(SmimeCertificates), k);
- if (mutt_strcasecmp (k, SmimeSignAs))
+ if (mutt_strcasecmp (k, SmimeDefaultKey))
smime_void_passphrase ();
safe_free ((void **) &k);
@@ -737,7 +740,7 @@ void _smime_getkeys (char *mailbox)
if (*SmimeKeyToUse)
{
- if (!mutt_strcasecmp (SmimeSignAs,
+ if (!mutt_strcasecmp (SmimeDefaultKey,
SmimeKeyToUse + mutt_strlen (SmimeKeys)+1))
return;
@@ -745,10 +748,10 @@ void _smime_getkeys (char *mailbox)
}
snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
- NONULL (SmimeKeys), SmimeSignAs);
+ NONULL (SmimeKeys), SmimeDefaultKey);
snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
- NONULL (SmimeCertificates), SmimeSignAs);
+ NONULL (SmimeCertificates), SmimeDefaultKey);
}
void smime_getkeys (ENVELOPE *env)
@@ -756,6 +759,17 @@ void smime_getkeys (ENVELOPE *env)
ADDRESS *t;
int found = 0;
+ if (option (OPTSDEFAULTDECRYPTKEY) && SmimeDefaultKey && *SmimeDefaultKey)
+ {
+ snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
+ NONULL (SmimeKeys), SmimeDefaultKey);
+
+ snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
+ NONULL(SmimeCertificates), SmimeDefaultKey);
+
+ return;
+ }
+
for (t = env->to; !found && t; t = t->next)
if (mutt_addr_is_user (t))
{
@@ -1416,12 +1430,12 @@ BODY *smime_sign_message (BODY *a )
int err = 0;
int empty = 0;
pid_t thepid;
- char *intermediates = smime_get_field_from_db(NULL, SmimeSignAs, 1, 1);
+ char *intermediates = smime_get_field_from_db(NULL, SmimeDefaultKey, 1, 1);
if (!intermediates)
{
mutt_message(_("Warning: Intermediate certificate not found."));
- intermediates = SmimeSignAs; /* so openssl won't complain in any case */
+ intermediates = SmimeDefaultKey; /* so openssl won't complain in any case */
}
else
intermediates[mutt_strlen (intermediates)-1] = '\0';
@@ -1452,10 +1466,10 @@ BODY *smime_sign_message (BODY *a )
snprintf (SmimeKeyToUse, sizeof (SmimeKeyToUse), "%s/%s",
- NONULL(SmimeKeys), SmimeSignAs);
+ NONULL(SmimeKeys), SmimeDefaultKey);
snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s",
- NONULL(SmimeCertificates), SmimeSignAs);
+ NONULL(SmimeCertificates), SmimeDefaultKey);
snprintf (SmimeIntermediateToUse, sizeof (SmimeIntermediateToUse), "%s/%s",
NONULL(SmimeCertificates), intermediates);
diff --git a/smime.h b/smime.h
index 90f7fe1a..9c8a1e52 100644
--- a/smime.h
+++ b/smime.h
@@ -21,7 +21,7 @@
#include "crypt.h"
-WHERE char *SmimeSignAs;
+WHERE char *SmimeDefaultKey;
WHERE char *SmimeCryptAlg;
WHERE short SmimeTimeout;
WHERE char *SmimeCertificates;