Search code examples
opensslcertificatex509certificatemimesmime

Create S/MIME certificates


I am trying to generate S/MIME certificate using the solution provided here: https://serverfault.com/questions/103263/can-i-create-my-own-s-mime-certificate-for-email-encryption Solution:

openssl genrsa -des3 -out smime.key 4096
openssl req -new -key smime.key -out smime.csr
openssl x509 -req -days 365 -in smime.csr -CA ca.crt -CAkey ca.key -set_serial 1 -out smime.crt -setalias "Self Signed SMIME" -addtrust emailProtection -addreject clientAuth -addreject serverAuth -trustout
openssl pkcs12 -export -in smime.crt -inkey smime.key -out smime.p12

I want to provide credentials for signing mime data too. How can I possibly do that? Any help would be really appreciated.


Solution

  • You have already created the credentials for signing MIME in you first three commands. You can sign some text_to_sign.txt file with your smime.key and smime.crt:

    openssl smime -sign -in text_to_sign.txt -inkey smime.key -signer smime.crt