Certificates and cryptography with openssl

One of the most common forms of cryptography today is public-key cryptography. Public-key cryptography utilizes a public key and a private key. The system works by encrypting information using the public key. The information can then only be decrypted using the private key.

A common use for public-key cryptography is encrypting application traffic using a Secure Socket Layer (SSL) or Transport Layer Security (TLS) connection. For example, configuring Apache to provide HTTPS, the HTTP protocol over SSL. This allows a way to encrypt traffic using a protocol that does not itself provide encryption.
A Certificate is a method used to distribute a public key and other information about a server and the organization who is responsible for it. Certificates can be digitally signed by a Certificate Authority or CA. A CA is a trusted third party that has confirmed that the information contained in the certificate is accurate.

Types of Certificates

To set up a secure server using public-key cryptography, in most cases, you send your certificate request (including your public key), proof of your company's identity, and payment to a CA. The CA verifies the certificate request and your identity, and then sends back a certificate for your secure server. Alternatively, you can create your own self-signed certificate.

Continuing the HTTPS example, a CA-signed certificate provides two important capabilities that a self-signed certificate does not:
  • Browsers (usually) automatically recognize the certificate and allow a secure connection to be made without prompting the user.
  • When a CA issues a signed certificate, it is guaranteeing the identity of the organization that is providing the web pages to the browser.
Most Web browsers, and computers, that support SSL have a list of CAs whose certificates they automatically accept. If a browser encounters a certificate whose authorizing CA is not in the list, the browser asks the user to either accept or decline the connection. Also, other applications may generate an error message when using a self-singed certificate.
The process of getting a certificate from a CA is fairly easy. A quick overview is as follows:
  1. Create a private and public encryption key pair.
  2. Create a certificate request based on the public key. The certificate request contains information about your server and the company hosting it.
  3. Send the certificate request, along with documents proving your identity, to a CA. We cannot tell you which certificate authority to choose. Your decision may be based on your past experiences, or on the experiences of your friends or colleagues, or purely on monetary factors.
    Once you have decided upon a CA, you need to follow the instructions they provide on how to obtain a certificate from them.
  4. When the CA is satisfied that you are indeed who you claim to be, they send you a digital certificate.
  5. Install this certificate on your secure server, and configure the appropriate applications to use the certificate.

Generating a Certificate Signing Request (CSR)

Whether you are getting a certificate from a CA or generating your own self-signed certificate, the first step is to generate a key.
To generate the keys for the Certificate Signing Request (CSR) run the following command from a terminal prompt:
openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
unable to write 'random state'
e is 65537 (0x10001)
Enter pass phrase for server.key:
You can now enter your passphrase. For best security, it should at least contain eight characters. The minimum length when specifying -des3 is four characters. It should include numbers and/or punctuation and not be a word in a dictionary. Also remember that your passphrase is case-sensitive.
Re-type the passphrase to verify. Once you have re-typed it correctly, the server key is generated and stored in the server.key file.
You can also run your secure service without a passphrase. This is convenient because you will not need to enter the passphrase every time you start your secure service. But it is highly insecure and a compromise of the key means a compromise of the server as well.
In any case, you can choose to run your secure service without a passphrase by leaving out the -des3 switch in the generation phase or by issuing the following command at a terminal prompt:
openssl rsa -in server.key -out server.key.insecure
Once you run the above command, the insecure key will be stored in the server.key.insecure file. You can use this file to generate the CSR without passphrase.
To create the CSR, run the following command at a terminal prompt:
openssl req -new -key server.key -out server.csr
It will prompt you enter the passphrase. If you enter the correct passphrase, it will prompt you to enter Company Name, Once you enter all these details, your CSR will be created and it will be stored in the server.csr file. Site Name, Email Id, etc.
You can now submit this CSR file to a CA for processing. The CA will use this CSR file and issue the certificate. On the other hand, you can create self-signed certificate using this CSR.

Creating a Self-Signed Certificate

To create the self-signed certificate, run the following command at a terminal prompt:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
The above command will prompt you to enter the passphrase. Once you enter the correct passphrase, your certificate will be created and it will be stored in the server.crt file.
If your secure server is to be used in a production environment, you probably need a CA-signed certificate. It is not recommended to use self-signed certificate.

Installing the Certificate

You can install the key file server.key and certificate file server.crt, or the certificate file issued by your CA, by running following commands at a terminal prompt:
sudo cp server.crt /etc/ssl/certs
sudo cp server.key /etc/ssl/private
Now simply configure any applications, with the ability to use public-key cryptography, to use the certificate and key files. For example, Apache can provide HTTPS, Dovecot can provide IMAPS and POP3S, etc.


  • For more detailed instructions on using cryptography see the SSL Certificates HOWTO by tlpd.org
  • The PKI Page contains a list of Certificate Authorities.
  • The Wikipedia HTTPS page has more information regarding HTTPS.
  • For more information on OpenSSL see the OpenSSL Home Page.              


  1. A public key and other details about a server and the company in charge of it can be distributed using a certificate. A Certificate Authority, Monkey Dubai or CA, can digitally sign certificates. A CA is a dependable third party that has attested to the veracity of the data in the certificate.

  2. personal bankruptcy lawyers near me

    Certificates and cryptography play a pivotal role in securing our digital world. 🛡️ Certificates, like digital passports, ensure the authenticity and trustworthiness of websites and online communication. Meanwhile, cryptography, the art of encoding and decoding information, keeps our sensitive data safe from prying eyes. Together, they create a robust shield against cyber threats in today's interconnected landscape. 💻🔒 #CyberSecurity #DigitalProtection

  3. It's clear that you're passionate about the topic, and your enthusiasm shines through in your words. I can't wait to read more of your posts in the future! Divorcio en Nueva York Leyes

  4. This comment has been removed by the author.

  5. The Free Libre Open Source Lebanese Movement article explores the role of open-source technology in Lebanon, emphasizing its role in promoting innovation, community, and empowerment. It highlights the movement's social and economic progress, bridging the digital divide, and creating local talent opportunities, making it a valuable resource for those interested in technology, innovation, and community-building.New York State No Fault Divorce

  6. Understanding certificates and cryptography is like having the keys to a secure digital kingdom. It empowers individuals and organizations to navigate the vast online landscape with confidence, knowing that their sensitive information is shielded from prying eyes. 💼📈

    Reglas de Divorcio en Nueva York

  7. "Certificates and cryptography are the backbone of secure communication in our digital world. They're like the invisible shields that protect our data, ensuring that sensitive information remains confidential and transactions remain trustworthy. These certificates, with their intricate cryptographic techniques, are the unsung heroes of the internet, silently working to keep our online experiences safe and secure. In a world where data privacy is paramount, certificates and cryptography are the knights in shining armor we never see but always rely on."

    reckless driving lawyer Hunterdon County

  8. "Certificates and cryptography are the keys to securing our digital world. These invaluable tools provide the trust and security necessary for our online transactions, communications, and data protection. Understanding and mastering this intricate field is like holding the secret to safeguarding our digital lives. 🛡️🔐💻"

    Abogado Conducir Sin Licencia Condado de Morris

  9. Thank you for offering this valuable information about software and Https etc. Your dedication to education and making it accessible to all is greatly appreciated. Your efforts are helping learners like me gain new knowledge and skills, and we're thankful for the opportunity.
    ¿Cuáles son los Leyes Divorcio en Nueva York?
    Cuáles son los Motivos de Divorcio en Estado de Nueva York


  10. "Certificates and Cryptography with OpenSSL" is a comprehensive and authoritative guide that demystifies the intricacies of digital security. Through clear explanations and practical examples, this resource equips readers with the knowledge and skills needed to navigate the complexities of certificate management and cryptographic protocols using OpenSSL. Whether you're a beginner or an experienced practitioner, this book offers valuable insights and techniques for enhancing security in various contexts, from web servers to network communication. With its thorough coverage and accessible approach, it's an essential reference for anyone working with OpenSSL in the field of cybersecurity.
    personal injury law firm virginia


The Open Source Web Hosting company