Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Last active January 29, 2020 19:03
Show Gist options
  • Save danilobatistaqueiroz/6348f3b51e3c4a80cce69a27f3fcef60 to your computer and use it in GitHub Desktop.
Save danilobatistaqueiroz/6348f3b51e3c4a80cce69a27f3fcef60 to your computer and use it in GitHub Desktop.
configuring ssl on apache2

Configuring SSL on Apache2

Note
A self-signed SSL certificate is easy and free, but triggers an error in most modern browsers reporting that the connection is not private.
Let’s Encrypt offers browser trusted, free SSL certificates, but does not support Extended Validation (EV) or multi-domain (wildcard) certificates.
An Extended Validation Certificate (EV) is a certificate conforming to X.509 that proves the legal entity of the owner and is signed by a Certificate Authority key that can issue EV certificates.
To gain those features, a commercial SSL certificate must be used.

Generating the private key and the certificate (Self-Signed)

If you have a certificate file and a private key of an authority then you can jump this step

Open the command prompt:

$ cd {path-of-apache}\conf

if already not, include {path-of-apache}\bin in the %PATH%

$ set OPENSSL_CONF={path-of-apache}\conf\openssl.cnf

$ openssl req -new -out server.csr

$ openssl rsa -in privkey.pem -out server.key

$ openssl x509 -in server.csr -out server.cert -req -signkey server.key -days 365


Configuring httpd.conf

On {path-of-apache}\conf\httpd.conf

Uncomment the lines:

LoadModule ssl_module modules/mod_ssl.so

Include conf/extra/httpd-ssl.conf


Configuring httpd-ssl.conf

On {path-of-apache}\conf\extra\httpd-ssl.conf

Change the properties ServerName and DocumentRoot according the environment.

Add the Directory tag, uncomment the two lines for SSL files.

DocumentRoot "{path-of-apache}/htdocs"
ServerName danilo.com:443
SSLCertificateFile "{path-of-apache}/conf/server.cert"
SSLCertificateKeyFile "{path-of-apache}/conf/server.key"
<Directory "C:/php/apache2/htdocs">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
	Require all granted
</Directory>

Run apache via command to analyse the errors

There are some errors that aren't logged, they are only showned on prompt.

Than on prompt call:

$ httpd


Enter your url in the browser:

https_url


Links:

https://stackoverflow.com/questions/33310611/how-to-configure-ssl-on-apache-2-4-windows-7

http://rubayathasan.com/tutorial/apache-ssl-on-windows/

http://smallbusiness.chron.com/configure-apache-ssl-windows-46530.html

https://gist.github.com/nguyenanhtu/33aa7ffb6c36fdc110ea8624eeb51e69

http://www.entrust.net/knowledge-base/technote.cfm?tn=6555

http://support.etouch.net/cm/wiki/?id=33381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment