3 test_description='S/MIME signature verification and decryption'
4 . ./test-lib.sh || exit 1
9 [ -d ${GNUPGHOME} ] && return
10 mkdir -m 0700 "$GNUPGHOME"
11 gpgsm --no-tty --no-common-certs-import --disable-dirmngr --import < $TEST_DIRECTORY/smime/test.crt >"$GNUPGHOME"/import.log 2>&1
12 fpr=$(gpgsm --list-key test_suite@notmuchmail.org | sed -n 's/.*fingerprint: //p')
13 echo "$fpr S relax" >> $GNUPGHOME/trustlist.txt
14 test_debug "cat $GNUPGHOME/import.log"
17 test_require_external_prereq openssl
18 test_require_external_prereq gpgsm
20 cp $TEST_DIRECTORY/smime/key+cert.pem test_suite.pem
22 FINGERPRINT=$(openssl x509 -fingerprint -in test_suite.pem -noout | sed -e 's/^.*=//' -e s/://g)
26 test_begin_subtest "emacs delivery of S/MIME signed message"
29 "test signed message 001" \
30 "This is a test signed message." \
31 "(mml-secure-message-sign \"smime\")"'
33 test_begin_subtest "emacs delivery of S/MIME encrypted + signed message"
34 # Hard code the MML to avoid several interactive questions
37 "test encrypted message 001" \
38 "<#secure method=smime mode=signencrypt keyfile=\\\"test_suite.pem\\\" certfile=\\\"test_suite.pem\\\">\nThis is a test encrypted message.\n"'
40 test_begin_subtest "Signature verification (openssl)"
41 notmuch show --format=raw subject:"test signed message 001" |\
42 openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
44 Verification successful
46 test_expect_equal_file EXPECTED OUTPUT
48 test_begin_subtest "signature verification (notmuch CLI)"
49 output=$(notmuch show --format=json --verify subject:"test signed message 001" \
50 | notmuch_json_show_sanitize \
51 | sed -e 's|"created": [-1234567890]*|"created": 946728000|' \
52 -e 's|"expires": [-1234567890]*|"expires": 424242424|' )
53 expected='[[[{"id": "XXXXX",
56 "filename": ["YYYYY"],
57 "timestamp": 946728000,
58 "date_relative": "2000-01-01",
59 "tags": ["inbox","signed"],
60 "headers": {"Subject": "test signed message 001",
61 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
62 "To": "test_suite@notmuchmail.org",
63 "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
65 "sigstatus": [{"status": "good",
66 "fingerprint": "'$FINGERPRINT'",
68 "created": 946728000}],
69 "content-type": "multipart/signed",
71 "content-type": "text/plain",
72 "content": "This is a test signed message.\n"},
74 "content-disposition": "attachment",
75 "content-length": "NONZERO",
76 "content-transfer-encoding": "base64",
77 "content-type": "application/x-pkcs7-signature",
78 "filename": "smime.p7s"}]}]},
80 test_expect_equal_json \
84 test_begin_subtest "Decryption and signature verification (openssl)"
85 notmuch show --format=raw subject:"test encrypted message 001" |\
86 openssl smime -decrypt -recip test_suite.pem |\
87 openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
89 Verification successful
91 test_expect_equal_file EXPECTED OUTPUT