<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Danny Tsang &#187; ssl</title> <atom:link href="http://www.dannytsang.co.uk/index.php/tag/ssl/feed/" rel="self" type="application/rss+xml" /><link>http://www.dannytsang.co.uk</link> <description>Eats and spits code by day</description> <lastBuildDate>Tue, 31 Jan 2012 22:47:19 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Create And Enable SSL On Ubuntu LAMP Server</title><link>http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/</link> <comments>http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/#comments</comments> <pubDate>Tue, 22 Mar 2011 00:01:00 +0000</pubDate> <dc:creator>Danny</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Website]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[apache ssl]]></category> <category><![CDATA[crt]]></category> <category><![CDATA[CSR]]></category> <category><![CDATA[HTTPS]]></category> <category><![CDATA[ssl]]></category> <category><![CDATA[ssl certificate]]></category> <category><![CDATA[VirtualHost]]></category> <guid
isPermaLink="false">http://www.dannytsang.co.uk/?p=3373</guid> <description><![CDATA[Introduction SSL is used to encrypt data between the client e.g a user viewing a website to the web server which hosts the site. SSL uses certificates which are signed and verify the validity of a website. Like any vendor &#8230; <a
href="http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/">Continue reading <span
class="meta-nav">&#8594;</span></a> Related posts:<ol><li><a
href='http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/' rel='bookmark' title='Enable SFTP On VSFTPD In Ubuntu'>Enable SFTP On VSFTPD In Ubuntu</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/awstats/' rel='bookmark' title='Awstats'>Awstats</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/apache-2-hardening-tips/' rel='bookmark' title='Apache 2 Hardening Tips'>Apache 2 Hardening Tips</a></li></ol>]]></description> <content:encoded><![CDATA[<h3>Introduction</h3><p><a
href="http://www.dannytsang.co.uk/index.php/tag/ssl/" class="st_tag internal_tag" rel="tag" title="Posts tagged with ssl">SSL</a> is used to encrypt data between the client e.g a user viewing a website to the web <a
href="http://www.dannytsang.co.uk/index.php/tag/server/" class="st_tag internal_tag" rel="tag" title="Posts tagged with server">server</a> which hosts the site. SSL uses certificates which are signed and verify the validity of a website. Like any vendor based system the certificate is as secure as the issuer. This means anyone can generate an <a
href="http://www.dannytsang.co.uk/index.php/tag/ssl-certificate/" class="st_tag internal_tag" rel="tag" title="Posts tagged with ssl certificate">SSL certificate</a> but only &#8220;certified vendors&#8221; are considered safe.</p><h3>Pre-requisites</h3><p>This post assumes <a
href="http://www.dannytsang.co.uk/index.php/tag/apache/" class="st_tag internal_tag" rel="tag" title="Posts tagged with apache">Apache</a> 2 is installed on <a
href="http://www.dannytsang.co.uk/index.php/tag/ubuntu/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Ubuntu">Ubuntu</a> 10.04 (other versions may apply) with no issues. The default virtual host will be used as the example.</p><h3>Install SSL</h3><ol><li>Ensure the SSL mod is installed so Apache can handle SSL requests <code>sudo apt-get install ssl-cert</code></li><li>Enable the SSL module <code>sudo a2enmod ssl</code></li><li>Before restarting the service, edit <code>/etc/apache2/ports.conf</code> and make sure there is a <strong>Listen 443</strong> in the file. Alternatively add it in and if the entry is invalid apache won&#8217;t start.</li><li>Create a directory to store the SSL certificates <code>sudo mkdir /etc/apache2/ssl</code></li><li>Restart apache service <code>sudo service apache2 restart</code></li></ol><h3>Generate SSL Certificate</h3><blockquote><p>Only run steps in this section if the certificate to be used is not going to be issued by a vendor.</p></blockquote><ol><li>Create the certificate in the <a
href="http://www.dannytsang.co.uk/index.php/tag/apache-ssl/" class="st_tag internal_tag" rel="tag" title="Posts tagged with apache ssl">Apache SSL</a> directory <code>sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/www.dannytsang.com.<a
href="http://www.dannytsang.co.uk/index.php/tag/crt/" class="st_tag internal_tag" rel="tag" title="Posts tagged with crt">crt</a></code></li></ol><p>Once complete go to <a
href="#VirtualHost">Configure Apache 2</a></p><h3>Applying For SSL</h3><p>The steps may vary but this is what I had to go through to obtain an SSL certificate:</p><ol><li>Install OpenSSL <code>sudo apt-get install openssl</code></li><li>Generate a <a
href="http://www.dannytsang.co.uk/index.php/tag/rsa/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rsa">RSA</a> private key. Enter a password when prompted <code>openssl genrsa -des3 -out www.dannytsang.com.key 2048</code></li><li>Create the <a
href="http://www.dannytsang.co.uk/index.php/tag/csr/" class="st_tag internal_tag" rel="tag" title="Posts tagged with CSR">CSR</a> <code>openssl req -new -key www.dannytsang.com.key -out www.dannytsang.com.csr</code> Example information:<ul><li>Country Name (2 letter code) [AU]:GB</li><li>State or Province Name (full name) [Some-State]:Hertfordshire</li><li>Locality Name (eg, city) []:Stevenage</li><li>Organization Name (eg, company) [GX Networks Ltd]:Danny Tsang</li><li>Organizational Unit Name (eg, section) []:</li><li>Common Name (eg, YOUR name) []:www.dannytsang.com</li><li>Leave the rest blank</li></ul></li><li>Ensure the CSR details are correct <code>openssl req -noout -text -in www.dannytsang.com.csr</code> If not go through the steps above again to re-generate the CSR</li><li>Submit the CSR to the vendor.</li><li>The vendor will verify details submitted before issuing the SSL certificate. Once that is complete continue to the next stage.</li><p>Depending on the level of the SSL certificate applied there is always at least 2 certificates that have to be included in Apache. One is the Vendor who signs the SSL and the SSL certificate itself.</p><li>Copy the vendor certificate to <code>sudo mkdir /etc/apache2/ssl</code>. For example <code>sudo vi /etc/apache2/ssl/CaCert.pem</code></li><li>Copy the site / domain SSL certificate <code>sudo vi /etc/apache2/ssl/www.dannytsang.com.crt</code></li></ol><h3><a
name="VirtualHost">Configure Apache 2</a></h3><p>There are various ways to enable <a
href="http://www.dannytsang.co.uk/index.php/tag/https/" class="st_tag internal_tag" rel="tag" title="Posts tagged with HTTPS">HTTPS</a> on a website. The options described below are the ones discussed in this article:</p><ul><li>Site Wide &#8211; The whole site uses HTTPS so that all the traffic is encrypted. This is the most secure method. Some limitations with this include any &#8220;resources&#8221; displayed on the site not from a HTTPS site will show a warning to the user. Website traffic will still be encrypted but not for non HTTPS parts e.g Ads</li><li>Login / Accounts only &#8211; From user log in and onwards will be encrypted. Other parts are not.</li></ul><p>For Login / Accounts only part, WordPress will be used as the example.</p><p>For both options there should be 2 virtual hosts configured in Apache. One for non encrypted and the other for encrypted. If the desired effect is for the user to explicitly type https into the browser then only the secure virtual host is need. Otherwise a redirect will be created so that users entering http://www.dannytsang.com will automatically go to https://www.dannytsang.com. The following will assume the virtual host file have already been created and working. The virtual host file will be called dannytsang.</p><ol><li>Make a copy of the virtual host which will be used for the SSL part of the site <code>sudo cp /etc/apache2/sites-available/dannytsang /etc/apache2/sites-available/dannytsangssl</code></li><li>Edit the secure virtual host file and make the following changes:<ul><li>Change the port to 443, the default port for HTTPS traffic e.g &lt;<a
href="http://www.dannytsang.co.uk/index.php/tag/virtualhost/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VirtualHost">VirtualHost</a> *:443&gt;</li><li>ServerName &#8211; Ensure this directive is set to the same as the SSL certificate e.g ServerName www.dannytsang.com</li><li>SSLEngine &#8211; Turn SSL on e.g SSLEngine On</li><li>SSLCACertificateFile &#8211; Path to the vendor or &#8220;Certificate Authority&#8221; signing certificate. This may be optional and not required if it was not mentioned by the issuer e.g SSLCACertificateFile /etc/apache2/ssl/CaCert.pem</li><li>SSLCertificateChainFile &#8211; Intermediate CA. Same as above e.g SSLCertificateChainFile /etc/apache2/ssl/ICaCert.pem</li><li>SSLCertificateFile  &#8211; Path to site SSL e.g SSLCertificateFile /etc/apache2/ssl/www.dannytsang.com.crt</li><li>SSLCertificateKeyFile &#8211; The file path to the private key used to sign the CSR e.g SSLCertificateKeyFile /etc/apache2/ssl/www.dannytsang.com.key</li><li>Save and exit the file</li></ul></li></ol><p>Example of the secure virtual host configuration file so far:</p><blockquote><p> &lt;VirtualHost *:443&gt;<br
/> ServerName www.dannytsang.com</p><p> SSLEngine On<br
/> SSLCertificateChainFile /etc/apache2/ssl/ICaCert.pem<br
/> SSLCertificateFile /etc/apache2/ssl/www.dannytsang.com.crt<br
/> SSLCertificateKeyFile /etc/apache2/ssl/www.dannytsang.com.key</p><p> DocumentRoot /var/www/dannytsang</p><p>&lt;/VirtualHost&gt;</p></blockquote><p>Note that my example does not contain <strong>SSLCACertificateFile</strong>. For a self generated SSL the only <strong>SSLCertificateFile</strong> is needed.</p><h4>Site Wide HTTPS</h4><p>One of the pit falls of site wide encryption is that all content must reside on the https domain or from other https sources. Below is an example of what Google&#8217;s Chrome browser would show if content didn&#8217;t come from a secured resource. In my case it was Ads:<br
/> <a
href="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-non-secure-content.png" rel="lightbox[3373]"><img
src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-non-secure-content-150x150.png" alt="" title="https non secure content" width="150" height="150" class="aligncenter size-thumbnail wp-image-3408" /></a></p><ol><li>Edit the non secure virtual host file of the site <code>sudo vi /etc/apache2/sites-available/dannytsang</code></li><li>Add the following lines below the SSL related directives:<br
/> <code><br
/> &lt;IfModule mod_rewrite.c&gt;<br
/> RewriteEngine on<br
/> RewriteCond %{SERVER_PORT} !^443$<br
/> RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]<br
/> &lt;/IfModule&gt;<br
/> </code></li><li>Save and exit the virtual host file.</li><li>Enable the new secure virtual host <code>sudo a2ensite dannytsangssl</code></li><li>Restart Apache <code>sudo service apache2 restart</code></li></ol><h4>Login HTTPS For WordPress</h4><ol><li>Edit the non secure virtual host file <code>sudo vi /etc/apache2/sites-available/dannytsang</code></li><li>Add the following inside the &lt;Directory /var/www/dannytsang&gt;:<br
/> <code><br
/> &lt;Directory /var/www/dannytsang&gt;<br
/> &lt;IfModule mod_rewrite.c&gt;<br
/> RewriteEngine On<br
/> RewriteBase /<br
/> RewriteCond %{REQUEST_FILENAME} -f [OR]<br
/> RewriteCond %{REQUEST_FILENAME} -d<br
/> RewriteRule ^wp-(admin|login|register)(.*) https://%{SERVER_NAME}/wp-$1$2 [L]<br
/> &lt;/IfModule&gt;<br
/> &lt;/Directory&gt;<br
/> </code><br
/> The RewriteRule is the rule for when it would change the URL to https. In this case it looks for any of the following combinations after the domain wp-admin, wp-login, wp-register e.g www.dannytsang.com/wp-login.php. Multiple rules may be added to match all sorts of sub directories.</li><li>Save and exit the virtual host file.</li><li>Add the following line to the non secure site so that going from a login / admin page to the normal part of the site e.g logging out and going back to the front page will change it to non https<br
/> <code>vi /etc/apache2/sites-available/dannytsang</code><br
/> <code><br
/> &lt;Directory /var/www/dannytsang&gt;<br
/> &lt;IfModule mod_rewrite.c&gt;<br
/> RewriteEngine On<br
/> RewriteBase /<br
/> RewriteRule !^wp-(admin|login|register)(.*) - [C]<br
/> RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [L]<br
/> &lt;/IfModule&gt;<br
/> &lt;/Directory&gt;<br
/> </code></li><li>Save and exit the virtual host file.</li><li>Enable mod_rewrite in Apache <code>sudo a2enmod rewrite</code></li><li>Enable the new secure virtual host <code>sudo a2ensite dannytsangssl</code></li><li>Restart Apache <code>sudo service apache2 restart</code></li><li>Edit the WordPress config file (wp-config.php) and add the following line to the bottom of the file <code>define('FORCE_SSL_ADMIN', true);</code></ol><h3>Debugging Tools &#038; Methods</h3><p>I found Google Chrome to be the best browser to troubleshoot SSL problems. Chrome is the most promient in showing HTTPS problems (see non secure sources screenshot above). The problem with Chrome was that it was more strict on showing the &#8220;padlock&#8221; HTTPS icon.<br
/> <a
href="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-cross.png" rel="lightbox[3373]"><img
src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-cross-150x94.png" alt="" title="https cross" width="150" height="94" class="aligncenter size-thumbnail wp-image-3424" /></a><br
/> Go to the Console in Chrome (Ctrl+Shift+j > Console tab) lists insure content warnings.<br
/> <a
href="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/insure-content.png" rel="lightbox[3373]"><img
src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/insure-content-150x150.png" alt="" title="insure content" width="150" height="150" class="aligncenter size-thumbnail wp-image-3425" /></a></p><h3>Summary</h3><p>Whilst going through this setup process myself it has been a long and arduous process (even if it doesn&#8217;t look it from this write up). I have learnt:</p><ul><li>Check the Certificate Authority &#8211; Ensure it is from a reputable organization issuing / signing the SSL. SSL providers are not necessarily the company which signs them. Also cheap SSLs may be signed by an unknown / not recognised as a verified CA. This list of CA vary from browser to browser.</li><li>Non secure SSL &#8211; Even if a page or site is encrypted using the HTTPS protocol, the page is not deemed secure if any information on a page comes from a non secure site.</li><li>Check WordPress Plugins &#8211; Some plugins are not HTTPS aware for example lightbox2.</li><li>Clear Cookies &#038; Cache &#8211; Sometimes browsers cache information and so even restarting the webserver may still result in an unsecure page / site. I found the best practice was to close the browser and start it up again. A quicker way to do it is to clear the cache and cookies associated with the site.</li></ul> <a
href='http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/https-non-secure-content/' title='https non secure content'><img
width="150" height="150" src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-non-secure-content-150x150.png" class="attachment-thumbnail" alt="https non secure content" title="https non secure content" /></a> <a
href='http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/https-cross/' title='https cross'><img
width="150" height="94" src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/https-cross-150x94.png" class="attachment-thumbnail" alt="https cross" title="https cross" /></a> <a
href='http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/insure-content/' title='insure content'><img
width="150" height="150" src="http://www.dannytsang.co.uk/wp-content/uploads/2011/03/insure-content-150x150.png" class="attachment-thumbnail" alt="insure content" title="insure content" /></a><p><a
href="https://help.ubuntu.com/community/forum/server/apache2/SSL" target="_blank">forumserverapache2SSL<br
/> </a></p><p><a
href="http://www.123-support.co.uk/support/answers/generate-a-csr-apache-open-ssl-634/" target="_blank">Generate a CSR: Apache (Open SSL)</a></p><p><a
href="http://codex.wordpress.org/Administration_Over_SSL" target="_blank">WordPress Administration Over SSL</a></p><p><a
href="http://ubuntuforums.org/showthread.php?t=895633"  target="_blank">apache2 &#8211; redirect http to https</a></p><p><a
href="https://search.thawte.com/support/ssl-digital-certificates/index?page=content&#038;actp=CROSSLINK&#038;id=SO15464" target="_blank">Intermediate Certificate Authority (CA) &#038; SSL Installation Instructions for Apache</a></p><p>Related posts:<ol><li><a
href='http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/' rel='bookmark' title='Enable SFTP On VSFTPD In Ubuntu'>Enable SFTP On VSFTPD In Ubuntu</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/awstats/' rel='bookmark' title='Awstats'>Awstats</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/apache-2-hardening-tips/' rel='bookmark' title='Apache 2 Hardening Tips'>Apache 2 Hardening Tips</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Enable SFTP On VSFTPD In Ubuntu</title><link>http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/</link> <comments>http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/#comments</comments> <pubDate>Sun, 31 Jan 2010 00:01:41 +0000</pubDate> <dc:creator>Danny</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[dsa]]></category> <category><![CDATA[ftp server]]></category> <category><![CDATA[rsa]]></category> <category><![CDATA[security certificates]]></category> <category><![CDATA[SFTP]]></category> <category><![CDATA[ssl]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[VSFTPD]]></category> <guid
isPermaLink="false">http://www.dannytsang.co.uk/?p=2487</guid> <description><![CDATA[Enabling SFTP is very easy and makes FTP protocol a lot more secure than traditional FTP because passwords are not sent in plain text which is susceptible to a lot of things such as packet sniffers, man-in-the-middle, etc. Assuming VSFTPD &#8230; <a
href="http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/">Continue reading <span
class="meta-nav">&#8594;</span></a> Related posts:<ol><li><a
href='http://www.dannytsang.co.uk/index.php/removing-files-with/' rel='bookmark' title='Removing Files With &#8211;'>Removing Files With &#8211;</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/' rel='bookmark' title='Create And Enable SSL On Ubuntu LAMP Server'>Create And Enable SSL On Ubuntu LAMP Server</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/enabling-remote-access-to-mysql/' rel='bookmark' title='Enabling Remote Access To MySQL'>Enabling Remote Access To MySQL</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Enabling <a
href="http://www.dannytsang.co.uk/index.php/tag/sftp/" class="st_tag internal_tag" rel="tag" title="Posts tagged with SFTP">SFTP</a> is very easy and makes FTP protocol a lot more secure than traditional FTP because passwords are not sent in plain text which is susceptible to a lot of things such as packet sniffers, man-in-the-middle, etc.</p><p>Assuming <a
href="http://www.dannytsang.co.uk/index.php/tag/vsftpd/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VSFTPD">VSFTPD</a> has been installed (in the default location) edit the file <strong>/etc/vsftpd.conf</strong> and check there are <a
href="http://www.dannytsang.co.uk/index.php/tag/security/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Security">security</a> certificates installed and configured.</p><p>There are two entries which start with either:<br
/> <code><a
href="http://www.dannytsang.co.uk/index.php/tag/dsa/" class="st_tag internal_tag" rel="tag" title="Posts tagged with dsa">dsa</a>_cert_file<br
/> dsa_private_key_file</code><br
/> or<br
/> <code><a
href="http://www.dannytsang.co.uk/index.php/tag/rsa/" class="st_tag internal_tag" rel="tag" title="Posts tagged with rsa">rsa</a>_cert_file<br
/> rsa_private_key_file</code><br
/> Each specifying a file path to where the key and certificates are located.</p><p>The last step is to enable SFTP by adding the following line:<br
/> <code><a
href="http://www.dannytsang.co.uk/index.php/tag/ssl/" class="st_tag internal_tag" rel="tag" title="Posts tagged with ssl">ssl</a>_enable=YES</code><br
/> Save and exit the file and restart the FTP <a
href="http://www.dannytsang.co.uk/index.php/tag/server/" class="st_tag internal_tag" rel="tag" title="Posts tagged with server">server</a> <code>sudo /etc/init.d/vsftpd restart</code></p><p>Related posts:<ol><li><a
href='http://www.dannytsang.co.uk/index.php/removing-files-with/' rel='bookmark' title='Removing Files With &#8211;'>Removing Files With &#8211;</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/create-and-enable-ssl-on-ubuntu-lamp-server/' rel='bookmark' title='Create And Enable SSL On Ubuntu LAMP Server'>Create And Enable SSL On Ubuntu LAMP Server</a></li><li><a
href='http://www.dannytsang.co.uk/index.php/enabling-remote-access-to-mysql/' rel='bookmark' title='Enabling Remote Access To MySQL'>Enabling Remote Access To MySQL</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://www.dannytsang.co.uk/index.php/enable-sftp-on-vsftpd-in-ubuntu/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
