3 test_description='S/MIME signature verification and decryption'
4 . $(dirname "$0")/test-lib.sh || exit 1
6 test_require_external_prereq openssl
7 test_require_external_prereq gpgsm
9 cp $NOTMUCH_SRCDIR/test/smime/key+cert.pem test_suite.pem
11 FINGERPRINT=$(openssl x509 -fingerprint -in test_suite.pem -noout | sed -e 's/^.*=//' -e s/://g)
15 test_begin_subtest "emacs delivery of S/MIME signed message"
18 "test signed message 001" \
19 "This is a test signed message." \
20 "(mml-secure-message-sign \"smime\")"'
22 test_begin_subtest "emacs delivery of S/MIME encrypted + signed message"
23 # Hard code the MML to avoid several interactive questions
26 "test encrypted message 001" \
27 "<#secure method=smime mode=signencrypt keyfile=\\\"test_suite.pem\\\" certfile=\\\"test_suite.pem\\\">\nThis is a test encrypted message.\n"'
29 test_begin_subtest "Signature verification (openssl)"
30 notmuch show --format=raw subject:"test signed message 001" |\
31 openssl smime -verify -CAfile $NOTMUCH_SRCDIR/test/smime/test.crt 2>OUTPUT
33 Verification successful
35 test_expect_equal_file EXPECTED OUTPUT
37 test_begin_subtest "signature verification (notmuch CLI)"
38 output=$(notmuch show --format=json --verify subject:"test signed message 001" \
39 | notmuch_json_show_sanitize \
40 | sed -e 's|"created": [-1234567890]*|"created": 946728000|g' \
41 -e 's|"expires": [-1234567890]*|"expires": 424242424|g' )
42 expected='[[[{"id": "XXXXX",
45 "filename": ["YYYYY"],
46 "timestamp": 946728000,
47 "date_relative": "2000-01-01",
48 "tags": ["inbox","signed"],
49 "crypto": {"signed": {"status": [{"fingerprint": "'$FINGERPRINT'", "status": "good","userid": "CN=Notmuch Test Suite","expires": 424242424, "created": 946728000}]}},
50 "headers": {"Subject": "test signed message 001",
51 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
52 "To": "test_suite@notmuchmail.org",
53 "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
55 "sigstatus": [{"fingerprint": "'$FINGERPRINT'",
57 "userid": "CN=Notmuch Test Suite",
59 "created": 946728000}],
60 "content-type": "multipart/signed",
62 "content-type": "text/plain",
63 "content": "This is a test signed message.\n"},
65 "content-disposition": "attachment",
66 "content-length": "NONZERO",
67 "content-transfer-encoding": "base64",
68 "content-type": "application/x-pkcs7-signature",
69 "filename": "smime.p7s"}]}]},
71 test_expect_equal_json \
75 test_begin_subtest "Decryption and signature verification (openssl)"
76 notmuch show --format=raw subject:"test encrypted message 001" |\
77 openssl smime -decrypt -recip test_suite.pem |\
78 openssl smime -verify -CAfile $NOTMUCH_SRCDIR/test/smime/test.crt 2>OUTPUT
80 Verification successful
82 test_expect_equal_file EXPECTED OUTPUT
84 test_begin_subtest "Decryption (notmuch CLI)"
85 test_subtest_known_broken
86 notmuch show --decrypt=true subject:"test encrypted message 001" |\
87 grep "^This is a" > OUTPUT
89 This is a test encrypted message.
91 test_expect_equal_file EXPECTED OUTPUT