skip book previous and next navigation links
go up to top of book: HP Open Source Security for OpenVMS Volume 2:... HP Open Source Security for OpenVMS Volume 2:...
go to beginning of reference: OpenSSL Command Line Interface (CLI) Reference OpenSSL Command Line Interface (CLI) Reference
go to previous page: sess_id sess_id
go to next page: speedspeed
end of book navigation links


smime
Description
Notes
Examples
 Command Options
Exit Codes
Restrictions

NAME

smime - S/MIME utility

Synopsis  

openssl smime [-encrypt] [-decrypt] [-sign] [-verify] [-pk7out] [-des] [-des3] [-rc2-40] [-rc2-64] [-rc2-128] [-in file] [-certfile file] [-signer file] [-recip file] [-inform SMIME|PEM|DER] [-passin arg] [-inkey file] [-out file] [-outform SMIME|PEM|DER] [-content file] [-to addr] [-from ad] [-subject s] [-text] [-rand file(s)] [cert.pem]...


return to top DESCRIPTION  

The smime command handles S/MIME mail. It can encrypt, decrypt, sign and verify S/MIME messages.


return to top COMMAND OPTIONS  

There are five operation options that set the type of operation to be performed. The meaning of the other options varies according to the operation type.


return to top NOTES  

The MIME message must be sent without any blank lines between the headers and the output. Some mail programs will automatically add a blank line. Piping the mail directly to sendmail is one way to achieve the correct format.

The supplied message to be signed or encrypted must include the necessary MIME headers or many S/MIME clients wont display it properly (if at all). You can use the -text option to automatically add plain text headers.

A "signed and encrypted" message is one where a signed message is then encrypted. This can be produced by encrypting an already signed message: see the examples section.

This version of the program only allows one signer per message but it will verify multiple signers on received messages. Some S/MIME clients choke if a message contains multiple signers. It is possible to sign messages "in parallel" by signing an already signed message.

The options -encrypt and -decrypt reflect common usage in S/MIME clients. Strictly speaking these process PKCS#7 enveloped data: PKCS#7 encrypted data is used for other purposes.


return to top EXIT CODES  


return to top EXAMPLES  

Create a cleartext signed message:
 openssl smime -sign -in message.txt -text -out mail.msg \
	-signer mycert.pem
Create and opaque signed message:
 openssl smime -sign -in message.txt -text -out mail.msg -nodetach \
	-signer mycert.pem
Create a signed message, include some additional certificates and read the private key from another file:
 openssl smime -sign -in in.txt -text -out mail.msg \
	-signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
Send a signed message under UNIX directly to sendmail, including
headers: 
 openssl smime -sign -in in.txt -text -signer mycert.pem \
	-from steve@openssl.org -to someone@somewhere \
	-subject "Signed message" | sendmail someone@somewhere
Verify a message and extract the signer's certificate if successful:
 openssl smime -verify -in mail.msg -signer user.pem -out signedtext.txt
Send encrypted mail using triple DES:
 openssl smime -encrypt -in in.txt -from steve@openssl.org \
	-to someone@somewhere -subject "Encrypted message" \
	-des3 user.pem -out mail.msg
Sign and encrypt mail:
 openssl smime -sign -in ml.txt -signer my.pem -text \
	| openssl smime -encrypt -out mail.msg \
	-from steve@openssl.org -to someone@somewhere \
	-subject "Signed and Encrypted message" -des3 user.pem
Note: the encryption command does not include the -text option because the message being encrypted already has MIME headers.

Decrypt mail:

 openssl smime -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
The output from Netscape form signing is a PKCS#7 structure with the detached signature format. You can use this program to verify the signature by line wrapping the base64 encoded structure and surrounding it with:
 -----BEGIN PKCS7-----
 -----END PKCS7-----
and using the command,
 openssl smime -verify -inform PEM -in signature.pem -content content.txt
alternatively you can base64 decode the signature and use
 openssl smime -verify -inform DER -in signature.der -content content.txt


return to top Restrictions  

The MIME parser isn't very clever: it seems to handle most messages that I've thrown at it but it may choke on others.

The code currently will only write out the signer's certificate to a file: if the signer has a separate encryption certificate this must be manually extracted. There should be some heuristic that determines the correct encryption certificate.

Ideally a database should be maintained of a certificates for each email address.

The code doesn't currently take note of the permitted symmetric encryption algorithms as supplied in the SMIMECapabilities signed attribute. this means the user has to manually include the correct encryption algorithm. It should store the list of permitted ciphers in a database and only use those.

No revocation checking is done on the signer's certificate.

The current code can only handle S/MIME v2 messages, the more complex S/MIME v3 structures may cause parsing errors.


go to previous page: sess_id sess_id
go to next page: speedspeed