Skip to content

Instantly share code, notes, and snippets.

@IchHabRecht
Created August 21, 2013 20:40
Show Gist options
  • Save IchHabRecht/6299970 to your computer and use it in GitHub Desktop.
Save IchHabRecht/6299970 to your computer and use it in GitHub Desktop.
[APACHE] SSL certificate
Step 1: Generate a Private Key
openssl genrsa -des3 -out server.key 1024
Step 2: Generate a CSR (Certificate Signing Request)
openssl req -new -key server.key -out server.csr
Step 3: Remove Passphrase from Key
cp server.key server.key.old
openssl rsa -in server.key.old -out server.key
Step 4: Generating a Self-Signed Certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Step 5: Installing the Private Key and Certificate
a2enmod ssl
mkdir /etc/apache2/ssl
cp server.crt /etc/apache2/ssl/ssl.crt
cp server.key /etc/apache2/ssl/ssl.key
Step 6: Virtuel Host
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
SSLEngine on
ServerSignature On
SSLCertificateFile /etc/apache2/ssl/ssl.crt
SSLCertificateKeyFile /etc/apache2/ssl/ssl.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
ErrorLog ${APACHE_LOG_DIR}/ssl-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl-access.log combined
</VirtualHost>
---
Certificate Signing Request for webserver
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment