Technical article 127954

How do I setup/configure/enable SSL for apache https connections?

OpenServer Definitive 2018UnixWare 7 Definitive 2018OpenServer 6UnixWare 7

Written · Last revised

Problem

Apache is not setup for https connections by default.

Most modern day web browser started requiring https connections in 2018.

The US Government HTTPS-Only Standard at:
https://https.cio.gov/

Google Makes the Switch To HTTPS Mandatory at:

https://rankmonsters.org/google-makes-the-switch-to-https-mandatory/

Solution

Create or setup Apache for SSL (https) and use - startssl option.

I. Create a Certificate Signing Request (CSR) using OpenSSL:

A. Generate a rsa key:
Without a Password
$ openssl genrsa -out www.yourdomain.com.key 2048
With a Password
$ openssl genrsa -des3 -out www.yourdomain.com.key 2048
To remove password from the above key
$ openssl rsa -in www.yourdomain.com.key \
          -out www.yourdomain.com.nopass.key

To view/inspect the key you just created.

$ openssl rsa -in www.yourdomain.com.key -noout -text

To extract the public key from the private key.

$ openssl rsa -in www.yourdomain.com.key -pubout \
          -out www.yourdomain.com.pubkey
NOTE:     The private key should never ever be sent or given to
          anyone! Use only the public key.  You use your private key
          prove you own it or to sign the Certificate Signing
          Request (CSR).
B. Generate a Certificate Request (CSR):

A Certificate Signing Request can be sent to a Certificate Authority (CA) to obtain a Trusted Certificate.

When prompted, enter the necessary information for
creating the CSR by using the conventions:  The following
characters cannot be used in the Organization Name or the
Organizational Unit: Characters between " ".
"< > ~ ! @ # $ % ^ * / \ ( ) ?.,&"

Country) The two-letter ISO abbreviation for your country. Example: US

State or Province) The state or province where your organization is legally located. Do not use an abbreviation. Example: Utah

Locality Name) IT City or Locality, The city where your organization is legally located. Example: Salt Lake City

Organization Name) The exact legal name of your organization. Do not abbreviate your organization name. Example: Your Company, Inc.

Organizational Unit)
Section of the organization.
Example: yourdomain.com
Common Name)
The fully qualified domain name for your web server. This
must be an exact match.  If you intend to secure the URL
https://www.yourdomain.com, then your CSR's common name
must be www.yourdomain.com.
Example: www.yourdomain.com
Email Address)
Address of responsible party.
Example: domain.admin@yourdomain.com

Warning: Leave the challenge password blank (press Enter).

This is an example of the command and output from it.

$ openssl req -new -sha256 -key www.yourdomain.com.key \
          -out www.yourdomain.com.csr

You will see something close to the following, you enter the information using the above guidelines:

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]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []: Email Address []:

Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:

You may look at the contents of the Certificate Signing Request (CSR).

$ openssl req -in www.yourdomain.com.csr -noout -text

You send the Certificate Signing Request (CSR) to whom ever you have generating your Certificate (CRT).

NOTE:     Make sure Signature Algorithm is not MD5. Old OpenSSL
          configurations have default_md = md5. Modern Web Browsers
          reject certificates that use md5 because of reject
          certificates that use md5  with md5.

II. Submit your Certificate Signing Request (CSR) to a CA or create an untrusted self-signed certificate:

A. To sign your CSR yourself using openssl:

req - We're generating a certificate -x509 - Create a SSL certificate following x509 specification -days 365 - The number of days a certificate is valid, 365 is one year -in www.yourdomain.com.csr - CSR generated for certificate -key www.yourdomain.com.key - Private Key used for certificate -out www.yourdomain.com.crt - The new signed certificate file

$ openssl req -x509 -nodes -days 365 -in www.yourdomain.com.csr \
   -key www.yourdomain.com.key -out www.yourdomain.com.crt

To create a self-signed key and crt files together:

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
   -keyout www.yourdomain.com.key -out www.yourdomain.com.crt
These are not trusted, but can be used for testing.  Copy them
into the default locations:
cp www.yourdomain.com.key /usr/lib/apache/conf/ssl.key/server.key
cp www.yourdomain.com.crt /usr/lib/apache/conf/ssl.crt/server.crt

B. Submit your Certificate Signing Request (CSR):

Send your CSR to a Certificate Authority (CA) for signing. For example:

Domains Made Easy - https://dnsmadeeasy.com/ Godaddy - https://www.godaddy.com/ Verisign - https://www.verisign.com/ Thawte - https://www.thawte.com/ RapidSSL - https://www.rapidsslonline.com/

There are other Certificate Authorities that you can choose
to use.   Having your certificate signed by a CA is required
if you want your keys to be trusted.
III. Install your SSL Certificate.

You will receive back from your CA some files in PEM format. Copy your files to the locations specified in:

/usr/lib/apache/conf/httpd.conf
The default locations are:
SSLCertificateFile /usr/lib/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/lib/apache/conf/ssl.key/server.key

Restart apache to test the new certificates:

/etc/apache stop
/etc/apache startssl

To setup apache to startup using SSL on the next boot edit /etc/rc2.d/P90apache and change SSL=no to SSL=yes

To test the connection with openssl use:

openssl s_client -connect www.yourdomain.com:443

This should show you the certificate associated with your site. If you have failures, check the ssl logs in /usr/lib/apache/logs/.

You can also test, by pointing your browser to the site:

https://www.yourdomain.com:443/

Results: https://www.yourdomain.com/ Hey, it worked ! The SSL/TLS-aware Apache webserver was successfully installed on this website.

NOTE:     If you used a self-signed certificate, then you will need to add
          an exception before your browser will make the connection to your
          site.

Privacy Enhanced Mail (PEM) is a Base64 encoded DER certificate. It contains very distinct headers and footers.

The header and footer identifies the type of file, not all PEM files are necessarily needed.

-----BEGIN CERTIFICATE REQUEST----- and -----END CERTIFICATE REQUEST----- a CSR in PEM format.

-----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- a private key in PEM format.

-----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- a certificate file in PEM format.

Below is a example of a Certificate in PEM format:

-----BEGIN CERTIFICATE----- miIDxDCCAqwCCQC8Is5uuYnOpjANBgkqhkiG9w0BAQQFADCBozELMAkGA1UEBhMC vsMxDTALBgNVBAgTBFV0YWgxGDAWBgNVBAcTD05vcnRoIFNhbHQgTGFrZTEZMBcG a1UEChMQTHluIERpc3RyaWJ1dGluZzEUMBIGA1UECxMLTWFpbiBPZmZpY2UxGDAW bgNVBAMTD3Bicy5seW5kaXN0LmNvbTEgMB4GCSqGSIb3DQEJARYRc2FsZXNAbHlu Z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ical article database, record 127954. Reproduced with permission. The original is at www.sco.com/ta/127954, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.