Cyber Services / All lessons / CEH — Ethical Hacking / Create CA Certificate

Create CA Certificate

Module 110 of 130 · 5 min read · Free to read

MODULES ↓ Command blocks have a COPY button

A comprehensive guide to establishing your own CA for S/MIME email encryption and signing

Purpose: Generating a personal CA is useful for internal organizational email security, testing S/MIME configurations, or securing communication among a small, trusted group where manually distributing the CA certificate is feasible.
Trust Implications: Certificates issued by your personal CA will not be automatically trusted by external parties or standard email clients/browsers. Recipients must manually import and trust your CA certificate to validate signatures or decrypt messages. This method is generally unsuitable for public communication.
1
Prerequisites
2
Generate CA Key
3
Create CA Certificate
4
Prepare for Import
5
Import to Thunderbird

Prerequisites

  • OpenSSL: A command-line tool for managing certificates and keys. It's pre-installed on most Linux systems (including Kali) and macOS. On Windows, you might need to install it (e.g., via Win32/Win64 OpenSSL or using WSL).
  • Terminal/Command Prompt: Access to a command-line interface.
  • Thunderbird Email Client: Installed and configured with your email account.
Verify OpenSSL installation
openssl version
Install OpenSSL on Debian/Ubuntu if needed
sudo apt update && sudo apt install -y openssl

Step 1: Generate the CA's Private Key

The private key is the secret foundation of your CA. It's used to sign all certificates issued by this CA. Keep it extremely secure!

Generate an Encrypted 4096-bit RSA Private Key (Recommended)

Generate CA private key
openssl genpkey -algorithm RSA -out ca-private-key.pem -aes256 -pkeyopt rsa_keygen_bits:4096
Command Explanation:
- genpkey: Command to generate private or public keys.
- -algorithm RSA: Use the RSA algorithm.
- -out ca-private-key.pem: Save the key to this file.
- -aes256: Encrypt the output key file with AES-256. You'll be prompted for a strong passphrase.
- -pkeyopt rsa_keygen_bits:4096: Use a strong 4096-bit key length.
Secure Your Private Key! Store ca-private-key.pem securely (e.g., encrypted USB drive, password manager). Use a strong, unique passphrase. If this key is compromised, your entire CA trust is broken.

Step 2: Generate the Self-Signed CA Certificate (Root Certificate)

This creates the public certificate for your CA, signed by its own private key. This is the certificate you will distribute and import into Thunderbird (and potentially other clients/systems).

Create the Self-Signed Certificate (Valid for 10 Years)

Generate CA certificate
openssl req -x509 -new -nodes -key ca-private-key.pem -sha256 -days 3650 -out ca-certificate.pem
Command Explanation:
- req: Command for certificate requests and generation.
- -x509: Output a self-signed certificate.
- -new: Generate a new certificate/request.
- -nodes: Do not encrypt the key reference *in this command's context*.
- -key ca-private-key.pem: Use this private key for signing.
- -sha256: Use the SHA-256 hash algorithm.
- -days 3650: Set validity for 10 years (adjust as needed).
- -out ca-certificate.pem: Save the certificate here (PEM format).

You will be prompted to enter the Distinguished Name (DN) information for your CA:

Certificate Details - Fill Appropriately (Example):
Enter pass phrase for ca-private-key.pem: [Your Secure Passphrase]
Country Name (2 letter code) [AU]:AE # Or your country
State or Province Name (full name) [Some-State]:Dubai
Locality Name (eg, city) []:Dubai
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Mubasher Cyber Academy CA
Organizational Unit Name (eg, section) []:Internal Security
Common Name (e.g. server FQDN or YOUR name) []:Mubasher Cyber Academy Email CA # IMPORTANT: Identifies your CA
Email Address []:ca-admin@Mubasher Cyber Academy.local # Optional admin email

The Common Name (CN) is crucial as it's the primary identifier for your CA in user interfaces.

Step 3: Prepare the CA Certificate for Import

While the .pem file created is often usable, renaming it to .crt is standard practice and helps applications like Thunderbird recognize it easily during import.

Rename the Certificate File (Recommended)

Rename certificate file
cp ca-certificate.pem mubasher_ca.crt

You now have mubasher_ca.crt ready for import.

Verify Certificate Content (Optional): You can view the details of your created certificate using:
View certificate details
openssl x509 -in mubasher_ca.crt -text -noout

Step 4: Import CA Certificate into Thunderbird

Instruct Thunderbird to trust your newly created CA certificate.

  1. Open Thunderbird.
  2. Go to the Menu (hamburger icon ☰) > Settings.
  3. In the search bar within the Settings tab, type certificates or scroll down to Privacy & Security.
  4. Under the "Certificates" section, click the Manage Certificates... button.
  5. In the Certificate Manager window that opens, select the Authorities tab.
  6. Click the Import... button.
  7. Navigate to the directory where you saved your CA certificate and select the mubasher_ca.crt file. Click Open.
  8. A dialog box "Downloading Certificate" will prompt you to set trust settings. Review the certificate details displayed to confirm it's yours. Then, check the appropriate boxes:
    • Trust this CA to identify email users. (Essential for S/MIME email signing/encryption validation).
    • Trust this CA to identify websites. (Check only if you plan to issue certificates for internal web servers accessed via Thunderbird).
    • Trust this CA to identify software makers. (Usually not needed for personal CAs).
  9. Click OK to confirm the trust settings, and then OK again to close the Certificate Manager.

Step 5: Verify CA Import

Confirm the successful import:

  1. Re-open the Certificate Manager (Settings > Search "Certificates" > Manage Certificates...).
  2. Select the Authorities tab.
  3. Scroll through the list or use the search bar to find the CA by the Organization Name or Common Name you entered during Step 2 (e.g., "Mubasher Cyber Academy CA" or "Mubasher Cyber Academy Email CA").
  4. Select your CA and click View... to double-check the details (Issuer, Validity, Fingerprints).

Next Steps & Usage

Using Your CA: With the CA created and trusted by Thunderbird:
  • Issue User Certificates for S/MIME: The next logical step is to use your ca-private-key.pem and mubasher_ca.crt to generate and sign individual user certificates (e.g., for user@example.com). These user certificates (in a format like PKCS#12 / .p12 containing both the cert and private key) are then imported into the "Your Certificates" tab in Thunderbird to enable email signing and decryption.
  • Issue Server Certificates: You can also use the CA to sign certificates for internal web servers, databases, etc., making their TLS connections trusted within your controlled environment (by clients that trust your CA).
Security Best Practices:
  • Protect your ca-private-key.pem file and its passphrase vigilantly. Consider hardware security modules (HSMs) or encrypted offline storage for production CAs.
  • Establish clear policies for certificate issuance and revocation if used within an organization.
  • Use appropriate validity periods for your CA and issued certificates.
  • Regularly back up your CA key and certificate.
Modules (130) ← CEH — Ethical Hacking