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_expect_success 'emacs delivery of S/MIME signed message' \
28 "test signed message 001" \
29 "This is a test signed message." \
30 "(mml-secure-message-sign \"smime\")"'
32 # Hard code the MML to avoid several interactive questions
33 test_expect_success 'emacs delivery of S/MIME encrypted + signed message' \
35 "test encrypted message 001" \
36 "<#secure method=smime mode=signencrypt keyfile=\\\"test_suite.pem\\\" certfile=\\\"test_suite.pem\\\">\nThis is a test encrypted message.\n"'
38 test_begin_subtest "Signature verification (openssl)"
39 notmuch show --format=raw subject:"test signed message 001" |\
40 openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
42 Verification successful
44 test_expect_equal_file EXPECTED OUTPUT
46 test_begin_subtest "signature verification (notmuch CLI)"
47 output=$(notmuch show --format=json --verify subject:"test signed message 001" \
48 | notmuch_json_show_sanitize \
49 | sed -e 's|"created": [-1234567890]*|"created": 946728000|' \
50 -e 's|"expires": [-1234567890]*|"expires": 424242424|' )
51 expected='[[[{"id": "XXXXX",
54 "filename": ["YYYYY"],
55 "timestamp": 946728000,
56 "date_relative": "2000-01-01",
57 "tags": ["inbox","signed"],
58 "headers": {"Subject": "test signed message 001",
59 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
60 "To": "test_suite@notmuchmail.org",
61 "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
63 "sigstatus": [{"status": "good",
64 "fingerprint": "'$FINGERPRINT'",
66 "created": 946728000}],
67 "content-type": "multipart/signed",
69 "content-type": "text/plain",
70 "content": "This is a test signed message.\n"},
72 "content-length": "NONZERO",
73 "content-transfer-encoding": "base64",
74 "content-type": "application/x-pkcs7-signature",
75 "filename": "smime.p7s"}]}]},
77 test_expect_equal_json \
81 test_begin_subtest "Decryption and signature verification (openssl)"
82 notmuch show --format=raw subject:"test encrypted message 001" |\
83 openssl smime -decrypt -recip test_suite.pem |\
84 openssl smime -verify -CAfile $TEST_DIRECTORY/smime/test.crt 2>OUTPUT
86 Verification successful
88 test_expect_equal_file EXPECTED OUTPUT