Email security become major issue as a lot of viruses, spam, fishing attempts use this method as major platform to attack individual and organization, one way is to sign & encrypt you emails so the receiving part can be 100% sure you are the sender and the email content can be trusted . S/MIME stands for Secure/Multipurpose Internet Mail Extensions . The best way is to buy certificate from trusted authority or try getting one for free valid for one year from here : https://www.actalis.it/products/certificates-for-secure-electronic-mail.aspx
However in this tutorial I will Show how to create self-signed certificate with self Authority .Lets begin.
First you will need to install OpenSSL on windows, and you can download it from here : https://slproweb.com/products/Win32OpenSSL.html or from here : http://gnuwin32.sourceforge.net/packages/openssl.htm
all the command you should run from command prompt under the installation directory in BIN folder. Lets say you have install it to :
So run the command from :
First lets create Private key for our Authority :
openssl genrsa -aes256 -out ca.key 4096
enter password for the key. Next Lets create self-sign certificate for our private authority valid for 3650 (10 years) :
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
Fill al the information in the wizard in order to create the certificate using the password you have selected before for the private key .
Next lets create an RSA Private Key for the Personal E-Mail Certificate, again you will have to create password for the private key :
openssl genrsa -aes256 -out smime_test_user.key 4096
We should create a file called smime.cnf in C:\OpenSSL-Win64\bin , Create text file->change its name to smime.cnf and enter this content as template for the certificate :
[req] distinguished_name = req_distinguished_name [req_distinguished_name] countryName = Country Name (2 letter code) countryName_default = AU countryName_min = 2 countryName_max = 2 stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = Some-State localityName = Locality Name (eg, city) 0.organizationName = Organization Name (eg, company) 0.organizationName_default = Internet Widgits Pty Ltd organizationalUnitName = Organizational Unit Name (eg, section) commonName = Common Name (e.g. server FQDN or YOUR name) commonName_max = 64 emailAddress = Email Address emailAddress_max = 40 [smime] basicConstraints = CA:FALSE keyUsage = nonRepudiation, digitalSignature, keyEncipherment subjectKeyIdentifier = hash authorityKeyIdentifier = keyid:always,issuer subjectAltName = email:copy extendedKeyUsage = emailProtection
Now we are ready to create CSR; Certificate Signing Request :
openssl req -new -key smime_test_user.key -out smime_test_user.csr
We now ready to create Certificate signed with our Private authority :
openssl x509 -req -days 3650 -in smime_test_user.csr -CA ca.crt -CAkey ca.key -set_serial 1 -out smime_test_user.crt -addtrust emailProtection -addreject clientAuth -addreject serverAuth -trustout -extfile smime.cnf -extensions smime
Now you have created self signed certificate with the Private authority, Although outlook and outher email client use p12 certificate style, Lets create this kind of certificate :
openssl pkcs12 -export -in smime_test_user.crt -inkey smime_test_user.key -out smime_test_user.p12
Enter the password you have created for the private key before . Now you have all the certificates you will need. in order to trust those certificates you will need to install them on the computer.
First install the ca.crt under Trusted Root Certificate authority as this will give the certificate validation, to do so :
run mmc-> file ->add/remove snap-ins-> select certificate -> computer account -> Local computer -> finish
Now Expand certificate and with the left mouse key import ca.crt to Trusted Root Certificate authority -> import smime_test_user.p12 under personal -> make sure the certificate is valid without errors
You shoud do it for both side computer, sender & receiver , is you have created self-signed on the receiver side this certificates should be install on all side (cert exchange) .
Installing the certificate on outlook as describe very nicely at https://www.ssl.com/how-to/installing-an-s-mime-certificate-and-sending-secure-email-with-outlook-on-windows-10 :
1. In Outlook, select File from the main menu, then click Options.
2. Select Trust Center at the bottom of the menu on the left side of the Outlook Options window.
3. Click Trust Center Settings.
4. Select Email Security from the left-hand menu of the Trust Center window.
5. Click Import/Export.
6. Make sure Import existing Digital ID from a file is checked, then click Browse…
7. Navigate to the PKCS#12 file, then click Open. The filename extension should be
8. Enter the password you used when downloading the PKCS#12 file, then click OK.
9. Click OK on the security dialog box that pops up.
10. Click Settings.
11. Enter a name for your security settings.
12. Click Choose, next to Signing Certificate. If you have only installed one certificate (as shown here), you can click OK on the Confirm Certificate dialog box that pops up. Otherwise, you will have to choose one from a list of installed certificates.
13. Click Choose, next to Encryption Certificate, and click OK on the Confirm Certificate dialog box. Again, if you have more than one certificate, select the same one you chose for Signing Certificate.
14. Click OK to close the Change Security Settings window.
15. Set your desired default options for S/MIME email via the four checkboxes under Encrypted email, then click OK to close the Trust Center Window.
The certificate is now installed and you can use it to digitally sign and encrypt messages in Outlook.
To send secure email in Outlook:
1. Begin composing a new email message in Outlook. Under Options, you can toggle the encryption and/or digital signature settings for the message.
2. After sending, click Allow in the Windows Security dialog box that appears, allowing Outlook to use your private key.
3. Note that if you attempt to send encrypted email and do not have your recipient’s public key, you will get an error message giving the option to send the message unencrypted.
When trying to send encryped email you might get error : valid certificate :
To Fix this you can import the certificate smime_test_user.p12 :
1. Open control panel, navigate to Network and Internet-> Internet Options. 2. In prompt Internet Properties Window, select “Content” tab->Click on “Certificates” button. 3. In prompt Certificate window, select “Personal” tab->Select the certificate you applied for and issued to your current account.
You can import again from there again the certificate