Tutorial

How To Create a SSL Certificate on Apache on Arch Linux

Published on November 10, 2012
How To Create a SSL Certificate on Apache on Arch Linux

About Self-Signed Certificates

A SSL certificate is a way to encrypt a site's information and create a more secure connection. Additionally, the certificate can show the virtual private server's identification information to site visitors. Certificate Authorities can issue SSL certificates that verify the server's details while a self-signed certificate has no 3rd party corroboration.

Set Up

The steps in this tutorial require the user to have root privileges on the VPS. You can see how to set that up in the Initial Server Setup in steps 3 and 4.

Additionally, you need to have apache already installed and running on your virtual server. If this is not the case, you can download it with this command:

sudo pacman -Syu
sudo pacman -S apache

Step One—Switch Into the Apache Config Directory

The first step is move into the main apache configuration directory. All of the subsequent steps will take place within the directory:

cd /etc/httpd/conf

Step Two—Create a Self Signed SSL Certificate

Start off by creating the 1024 rsa private key. The “-des3” option designates the need for a passphrase. Although having the passphrase in place does provide heightened security, the issue starts when one tries to reload apache. In the event that apache crashes or needs to reboot, you will always have to re-enter your passphrase to get your entire web server back online.

sudo openssl genrsa -des3 -out server.key 1024

Now it’s time to create a certificate-signing request. If you set up a passphrase in the previous step, you will be prompted to enter it in this step as well:

sudo openssl req -new -key server.key -out server.csr

This command will prompt terminal to display a lists of fields that need to be filled in.

The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address.

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:NYC
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc
Organizational Unit Name (eg, section) []:Dept of Merriment
Common Name (e.g. server FQDN or YOUR name) []:example.com                  
Email Address []:webmaster@awesomeinc.com

Finally, remove the passphrase:

sudo cp server.key server.key.org
sudo openssl rsa -in server.key.org -out server.key

Finish by specifying how long the certificate should remain valid by changing the 365 to the number of days you prefer. As it stands this certificate will expire after one year.

sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Step Three—Finish Up

Your certificate has been created and signed. You only have to be sure that apache includes it in its configuration. Go ahead and open up the main apache config file:

sudo nano /etc/httpd/conf/httpd.conf

Once there, uncomment the following line:

Include conf/extra/httpd-ssl.conf

Restart apache to put your changes into effect:

sudo systemctl restart httpd

In your browser, type https://youraddress, and you will be able to see the new self-signed certificate.

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
4 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

there’s a problem with loading modules in /etc/httpd/conf/extra/httpd-ssl.conf you have to comment out these lines in /etc/httpd/conf/httpd.conf :

LoadModule ssl_module modules/mod_ssl.so```
but there's one more problem ; i have to add exception to use *https://mydomain.com* !

I followed the instruction and now my webpage will not open, any help please

In file /etc/httpd/conf/httpd.conf There is no line containing Include conf/extra/httpd-ssl.conf Moreover after following All steps till Finish Step there is no file created “extra/httpd-ssl.conf”

Any suggestion ? Where I m wrong

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.