X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fcrypto.rb;h=8ec277b862603fb23d94a60d3fa19fd60ee0fd0f;hb=5057149d9c3b57c6b5c4d0964a0aae9d490aaa38;hp=9e16132304ebad107b8cab43c0706de82b6e1a78;hpb=11b3c59d8ae571c98e6a9fd2b882fcff6cbb3ff1;p=sup diff --git a/lib/sup/crypto.rb b/lib/sup/crypto.rb index 9e16132..8ec277b 100644 --- a/lib/sup/crypto.rb +++ b/lib/sup/crypto.rb @@ -40,7 +40,7 @@ class CryptoManager raise Error, (output || "gpg command failed: #{cmd}") unless $?.success? envelope = RMail::Message.new - envelope.header["Content-Type"] = 'multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1' + envelope.header["Content-Type"] = 'multipart/signed; protocol=application/pgp-signature; micalg=pgp-sha1' envelope.add_part payload signature = RMail::Message.make_attachment output, "application/pgp-signature", nil, "signature.asc" @@ -53,7 +53,7 @@ class CryptoManager payload_fn.write format_payload(payload) payload_fn.close - recipient_opts = to.map { |r| "--recipient '#{r}'" }.join(" ") + recipient_opts = (to + [ from ] ).map { |r| "--recipient '<#{r}>'" }.join(" ") sign_opts = sign ? "--sign --local-user '#{from}'" : "" gpg_output = run_gpg "--output - --armor --encrypt --textmode #{sign_opts} #{recipient_opts} #{payload_fn.path}" raise Error, (gpg_output || "gpg command failed: #{cmd}") unless $?.success? @@ -150,6 +150,8 @@ private ["Can't find gpg binary in path."] end + ## here's where we munge rmail output into the format that signed/encrypted + ## PGP/GPG messages should be def format_payload payload payload.to_s.gsub(/(^|[^\r])\n/, "\\1\r\n").gsub(/^MIME-Version: .*\r\n/, "") end