https://www.claws-mail.org/faq/api.php?action=feedcontributions&user=Tg&feedformat=atom Claws Mail FAQ - User contributions [en] 2024-03-29T05:23:26Z User contributions MediaWiki 1.35.7 https://www.claws-mail.org/faq/index.php?title=S/MIME_howto&diff=2134 S/MIME howto 2009-12-08T22:47:17Z <p>Tg: added include-certs option</p> <hr /> <div>==Claws Mail &amp; S/MIME plugin howto==<br /> This howto describes configuring S/MIME for Claws Mail which uses GnuPG. It is<br /> based on Gentoo Linux but should be working fine on every other distribution if<br /> adjusting it accordingly.<br /> &lt;br /&gt;<br /> <br /> As of 16th November 2009 Thawte discontinued their free S/MIME certificates. As<br /> some things of this howto were also somewhat out of date and many things were<br /> based on Thawte, it's time for an update. A big difference to the previous howto<br /> is enabling the use of certificate revocation lists (CRL) which didn't work<br /> properly with Thawte before. I won't use OCSP support because of privacy issues,<br /> see man dirmngr.<br /> <br /> ===Requirements===<br /> # recent Claws Mail version, recommended: latest available version (v3.7.3 at the time of writing this), because many fixes for S/MIME have been incorporated lately<br /> # most recent S/MIME plugin/package, or &quot;smime&quot; USE flag on Gentoo<br /> # S/MIME certificate (e.g. you can get free (personal use) certificates from Comodo at http://www.instantssl.com)<br /> # pinentry, gnupg, gpgme, dirmngr (for CRL support), ca-certificates (and openssl) in recent versions<br /> # gpg-agent<br /> &lt;br /&gt;<br /> It is important to note that gpgme &gt;=1.1.8 ''does not work for me'' and always<br /> results in an error message hence I have it masked here and use v1.1.6.<br /> See bug 2059: http://www.thewildbeast.co.uk/claws-mail/bugzilla/show_bug.cgi?id=2059<br /> &lt;br /&gt;<br /> I've tested this howto with the following package versions:<br /> &lt;br /&gt;<br /> # emerge -p pinentry gnupg gpgme ca-certificates dirmngr claws-mail<br /> [ebuild R ] app-crypt/pinentry-0.7.6 USE=&quot;gtk ncurses qt3 qt4 -caps -static&quot; 464 kB<br /> [ebuild R ] app-misc/ca-certificates-20090709 151 kB<br /> [ebuild R ] app-crypt/dirmngr-1.0.3 USE=&quot;nls&quot; 544 kB<br /> [ebuild R ] app-crypt/gnupg-2.0.13 USE=&quot;bzip2 ldap nls smartcard -adns -caps -doc -openct -pcsc-lite (-selinux) -static&quot; 3,855 kB<br /> [ebuild R ] app-crypt/gpgme-1.1.6 USE=&quot;-pth&quot; 1,061 kB<br /> [ebuild R ] mail-client/claws-mail-3.7.3 USE=&quot;bogofilter crypt dbus dillo gnome gnutls imap ipv6 kde ldap nntp session smime spamassassin ssl xface -doc -pda -spell -startup-notification&quot; 0 kB<br /> <br /> ===Configuring &amp; running the GPG agent===<br /> Claws Mail depends on a running gpg-agent for using any S/MIME feature. Furthermore<br /> it is used to cache the passphrase. A gpg-agent will need a pinentry<br /> application to ask for the pin.<br /> <br /> &lt;br /&gt;<br /> Configuration file: &quot;$HOME/.gnupg/gpg-agent.conf&quot; (adjust the paths accordingly)<br /> &lt;br /&gt;<br /> pinentry-program /usr/bin/pinentry-qt<br /> default-cache-ttl 86400 # be aware that the passphrases will be cached for 86400 seconds! set accordingly to your needs<br /> max-cache-ttl 86400<br /> disable-scdaemon<br /> write-env-file ~/.gnupg/.gpg-agent-info<br /> allow-mark-trusted<br /> keep-display<br /> display :0.0<br /> debug-level basic<br /> &lt;br /&gt;<br /> <br /> Running gpg-agent is quite trivial:<br /> <br /> eval `gpg-agent --daemon`<br /> <br /> As you see, it eval's the command, that means, gpg-agent returns an environment<br /> variable and exports it, something like `GPG_AGENT_INFO=xxx; export<br /> GPG_AGENT_INFO`. This means, that you will have to run claws-mail from the same<br /> session, because it will need this environment variable in order to access the<br /> agent. Check gpg-agent(1) for more details on the usual startup customs.<br /> <br /> ====KDE Users====<br /> KDE has a way to run scripts and thus export environment variables at startup<br /> time. Every application running in this session will get access to these variables. All<br /> you have to do is create a file under the directory ~/.kde/env/ (if it doesn't<br /> exist, then create it). I named it gpgagent.sh, the content of this shell script<br /> is quite trivial (don't forget to chmod +x):<br /> <br /> #!/bin/sh<br /> eval `gpg-agent --daemon`<br /> <br /> Also create the directory ~/.kde/shutdown/ and place another shell script in it<br /> (e.g. again gpgagent.sh) with the following contents:<br /> #!/bin/sh<br /> # the second field of the GPG_AGENT_INFO variable is the<br /> # process ID of the gpg-agent active in the current session<br /> # so we'll just kill that, rather than all of them :)<br /> [ -n &quot;${GPG_AGENT_INFO}&quot; ] &amp;&amp; kill `echo &quot;${GPG_AGENT_INFO}&quot; | cut -d ':' -f 2`<br /> <br /> <br /> ====Optional====<br /> You can also use keychain, ~/.xsession startup, or any other method to start<br /> gpg-agent. Choose what you like, here are somes howtos:<br /> &lt;br /&gt;<br /> http://www.funtoo.org/en/security/keychain/intro/&lt;br /&gt;<br /> http://www.gentoo-wiki.info/HOWTO_KMail_gpg-agent_kde#Setting_up_gpg-agent_with_keychain&lt;br /&gt;<br /> http://www.claws-mail.org/faq/index.php/Plugins#How_do_I_configure_gpg-agent_and_the_PGP_plugin.3F &lt;br /&gt;<br /> man gpg-agent, section DESCRIPTION<br /> <br /> <br /> ===Importing S/MIME certificates into gpgsm===<br /> Regardless whether you have obtained your S/MIME certificate in Mozilla Firefox<br /> or another browser, you have to export/backup it to a PKCS12 (.p12) file<br /> somewhere on your disk. I'm using the filename &quot;certbundle.p12&quot; for this howto,<br /> you can call it as you wish (e.g. $emailaddress_$certdate.p12)<br /> <br /> Current versions of GnuPG support importing PKCS12 files directly, there's no<br /> need to use openssl anymore, as described in the previous howto. (If it doesn't<br /> work for you, you can still view the old howto through the history and use<br /> openssl to extract and convert the keys). Gpg-agent has to be properly setup and<br /> running by now.<br /> &lt;br /&gt;<br /> $ gpgsm --import certbundle.p12<br /> &lt;br /&gt;<br /> You will be asked to enter your passphrase for the backup file in the pinentry<br /> popup and you then have choose another passphrase for importing it to gpgsm.<br /> This passphrase will be the one you have to enter everytime you want to decrypt<br /> or sign emails (of course there's the possibility to cache the passphrase).<br /> <br /> Now one has to add the issuer certificates (CA + intermediate CA) into gpgsm if<br /> they are not already there. The following command will add more than 100 CA certificates<br /> from the ca-certificates package, but you could also only add the specific CA's<br /> for your certificate if you want.<br /> &lt;br /&gt;<br /> $ gpgsm --import /usr/share/ca-certificates/mozilla/*<br /> <br /> Check if your key has been added:&lt;br /&gt;<br /> $ gpgsm --list-secret-keys<br /> <br /> <br /> ===Configuring GnuPG S/MIME===<br /> You'll now have to properly configure GnuPG for S/MIME. As opposed to the<br /> previous howto, we'll also be using certificate revocation list (CRL) support with dirmngr to<br /> be able to detect revoked certificates within the mail client. (It didn't work<br /> before because Thawte has some messed up CRL which GnuPG couldn't handle<br /> properly - but because Thawte doesn't provide S/MIME anymore, we're fine now :)<br /> We only have to import the large Thawte CRL once as all of their certificates<br /> have been revoked.<br /> &lt;br /&gt;<br /> <br /> This is my &quot;$HOME/.gnupg/gpgsm.conf&quot;:&lt;br /&gt;<br /> disable-policy-checks<br /> auto-issuer-key-retrieve<br /> include-certs -1 # this will include all certificates in the chain up to the root<br /> debug-level basic<br /> &lt;br /&gt;<br /> You will also probably want to enter the following entry to gpgsm.conf ( use<br /> the fingerprint output from the command &quot;gpgsm --list-secret-keys&quot;)<br /> default-key fingerprint_of_your_key<br /> <br /> &lt;br /&gt;<br /> My &quot;$HOME/.gnupg/dirmngr.conf&quot; file only contains the following line, everything<br /> is set to default. Dirmngr will be used for CRL support internally by GnuPG. It<br /> is also possible to setup a system-wide dirmngr daemon which is not part of this<br /> howto (see man page).<br /> debug-level basic<br /> &lt;br /&gt;<br /> If you encounter any problems with CRL support you can use the old<br /> configuration files from the history in this wiki which disables it. Be aware<br /> that by having imported all CA's dirmngr might encounter a CRL where it can't<br /> fetch it properly and hangs (sometimes happens to me when starting kleopatra).<br /> <br /> ====Importing Thawte CRL and testing CRL support====<br /> As of 16th November 2009 all Thawte S/MIME certificates have been revoked. As<br /> dirmngr doesn't automatically work with the Thawte CRL, one has to import them<br /> manually once. A working gpg-agent setup is again needed, then perform the<br /> following steps:<br /> # download the Thawte CRL<br /> wget http://crl.thawte.com/ThawtePersonalFreemailCA.crl<br /> wget http://crl.thawte.com/ThawtePersonalFreemailIssuingCA.crl<br /> <br /> # import to dirmngr<br /> gpgsm --call-dirmngr loadcrl ThawtePersonalFreemailCA.crl<br /> gpgsm --call-dirmngr loadcrl ThawtePersonalFreemailIssuingCA.crl<br /> &lt;br /&gt;<br /> If you have old Thawte certificates that are still valid according to their<br /> expiry date or other revoked certificates you can verify that dirmngr works with<br /> the following command:<br /> gpgsm --list-keys --with-validation &lt;keyid|name|fingerprint&gt;<br /> &lt;br /&gt;<br /> The output will be like this:<br /> [...]<br /> validity: 2009-03-24 08:26:26 through 2010-03-24 08:26:26<br /> key type: 2048 bit RSA<br /> fingerprint: xxxx<br /> [certificate has been revoked]<br /> [validation model used: shell]<br /> [certificate is bad: Certificate revoked]<br /> <br /> See &quot;[certificate is bad: Certificate revoked]&quot; message instead of<br /> &quot;[certificate is good]&quot;.<br /> <br /> ====Setting up the trust====<br /> We used the option &quot;allow-mark-trusted&quot; in gpg-agent.conf which allows the<br /> client to mark keys as trusted, i.e. put them in the file<br /> $HOME/.gnupg/trustlist.txt (see man gpg-agent). Hence you should be asked<br /> automatically to trust another key or CA, e.g. it mainly happens for me when I<br /> click on an email in Claws Mail where the CA is missing from trustlist.txt or<br /> when I start the tool &quot;kleopatra&quot; where I'm asked to trust the CAs.<br /> &lt;br /&gt;<br /> <br /> If it doesn't work for you automatically you have to create the file (if it<br /> doesn't exist) &quot;$HOME/.gnupg/trustlist.txt&quot; to add your CA (e.g. Comodo, Thawte)<br /> to the trusted key list. This makes it possible to verify/sign/.../ with your<br /> personal certificate. I also added my own certificate to the trustlist.<br /> &lt;br /&gt;<br /> <br /> Usually one adds the SHA1 fingerprints to the file (not the serial number, and<br /> it doesn't matter whether with or without the colon). With<br /> the following command (borrowed and adjusted from this German howto<br /> http://www.kire.ch/blog/2009/05/07/claws-mail-und-smime-verschlusselung-mit-cacert-zertifikat/)<br /> you can add all your CA's and keys at once (of course you have to trust all the CA's of<br /> the ca-certificate package - if you don't then you have to manually dump the<br /> certificate chain and add the fingerprints accordingly):<br /> &lt;br /&gt;<br /> gpgsm --list-keys 2&gt;/dev/null | grep fingerprint | awk '{print $2 &quot; S&quot;}' &gt;&gt; ~/.gnupg/trustlist.txt<br /> (the command will append, not overwrite the old file)<br /> &lt;br /&gt;<br /> Note that when manually changing trustlist.txt or gpg-agent.conf, you need to give<br /> gpg-agent a SIGHUP.<br /> &lt;br /&gt;<br /> <br /> ===Setting up Claws Mail itself===<br /> There's not much you have to configure in Claws Mail. Go to the menu &quot;Configuration - Edit Accounts | choose your account | - Edit - Account - Privacy - Default privacy system&quot; =&gt; S-MIME<br /> &lt;br /&gt;<br /> Set the options to your need, e.g. I've set all but the last (Save sent encrypted as clear text).<br /> &lt;br /&gt;<br /> As we have configured gpgsm to use a &quot;default key&quot; you can set &quot;Use default GnuPG key&quot; in the Account preferences Plugins/GPG menu.<br /> <br /> ===Working with Claws Mail S/MIME and problems/bugs===<br /> * If you receive the error message &quot;The signature can't be checked - Unknown IPC Command&quot; and you're using &quot;seahorse-agent&quot; try to switch to the gpg-agent of the GnuPG package. <br /> <br /> * If you encounter the error message &quot;Couldn't decrypt: No CMS object&quot; then it is likely that your gpgme version is incompatible with Claws Mail. In my tests only v1.1.6 worked, everything newer (1.1.8 and 1.2.0) doesn't work for me! This doesn't necessarily mean that it doesn't work for you. See http://www.thewildbeast.co.uk/claws-mail/bugzilla/show_bug.cgi?id=2059<br /> <br /> * Error message &quot;Cannot sign: General error&quot; usually means that there's something wrong with the gpg-agent (e.g. not running or wrong environment)<br /> <br /> * If you're an old Thawte user trying to use their offer for a free VeriSign S/MIME certificate with Claws Mail, you're out of luck because GnuPG doesn't support the ancient MD2 algorithm being used by VeriSign for their CA. I've tried getting it to work but never succeeded (except by using Thunderbird), here's a statement from the developer of GnuPG/libgcrypt: http://lists.gnupg.org/pipermail/gpa-dev/2003-October/001482.html<br /> <br /> * I'm only aware of one problem in Claws Mail, where you'll get &quot;Bad signature&quot; warnings, when you forward (via CM) a signed+encrypted email with an attachment and sign+encrypt the email itself again too.<br /> <br /> * Error message: Couldn't decrypt: &quot;unsupported algorithm&quot; - this happens when you receive an email which got encrypted with the RC2 algorithm (e.g. some Outlook and some Thunderbird MUAs). I'm currently not aware of a solution on your side, as the underlying libgcrypt doesn't handle it for patent reasons. (see https://intevation.de/roundup/aegypten/issue11 and http://forums.mozillazine.org/viewtopic.php?p=2858116 ) You can ask your email partner to reconfigure their clients though (I know that it works for recent Outlook versions on &gt;=Windows Vista to force certain algorithms).</div> Tg