<?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>dev.fuzzee.co.uk &#187; ssl</title>
	<atom:link href="http://dev.fuzzee.co.uk/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.fuzzee.co.uk</link>
	<description>stuff that pops into my head ... technical stuff.</description>
	<lastBuildDate>Sun, 18 Apr 2010 13:39:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Replication over SSL</title>
		<link>http://dev.fuzzee.co.uk/2009/06/mysql-replication-over-ssl/</link>
		<comments>http://dev.fuzzee.co.uk/2009/06/mysql-replication-over-ssl/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:36:41 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[stunnel]]></category>

		<guid isPermaLink="false">http://dev.fuzzee.co.uk/?p=9</guid>
		<description><![CDATA[A new project requires MySQL replication to be carried out over the internet. My first thought was to use stunnel, which I quickly implemented. This appeared to work perfectly (after some iptables configuration). However, I found out later that MySQL supports replication over SSL natively. I have made the assumption (perhaps mistakenly) that a native [...]]]></description>
			<content:encoded><![CDATA[<p>A new project requires MySQL replication to be carried out over the internet. My first thought was to use <a href="http://www.stunnel.org">stunnel</a>, which I quickly implemented. This appeared to work perfectly (after some iptables configuration). However, I found out later that MySQL supports replication over SSL natively. I have made the assumption (perhaps mistakenly) that a native solution would be better (more reliable?) than a wrapped solution. Getting MySQL replicating over SSL was perhaps about 30 minutes work in total. This could&#8217;ve been cut down to about 10 minutes if it wasn&#8217;t for some documentation-related issues.<br />
<span id="more-9"></span></p>
<ul>
<li>Read MySQL&#8217;s documentation on <a title="Creating SSL Certificates for MySQL" href="http://dev.mysql.com/doc/refman/5.0/en/secure-create-certs.html">creating SSL certificates</a> &#8211; follow <strong>Example 1</strong>, ignoring the bit about client certificates.</li>
<li>Make sure the slave can connect to the master on port 3306. For the security conscious, I don&#8217;t think this is as bad as it sounds &#8211; we restrict access by IP and  our master MySQL server will require SSL credentials.</li>
<li>Modify your master&#8217;s my.cnf file to include the ssl-* configuration options as per the <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-solutions-ssl.html">Replication over SSL document</a></li>
<li>Copy the master&#8217;s new ca-cert.pem, server-cert.pem and server-key.pem files to your slave machine</li>
<li>This is where I fell over &#8211; specify your certificate/key files in CHANGE MASTER TO as demonstrated <a href="http://dev.mysql.com/doc/refman/5.1/en/replication-solutions-ssl.html">here</a> and <strong>not</strong> in the my.cnf. For one reason or another, only the CHANGE MASTER TO method works.
<li><strong>On the DB Master </strong>:<code><br />
GRANT REPLICATION SLAVE ON *.* TO 'slave'@'slave-ip' IDENTIFIED BY 'slavepass' REQUIRE SSL;<br />
FLUSH PRIVILEGES;<br />
</code></li>
<li><strong>On the DB Slave </strong>: <code><br />
START SLAVE;<br />
SHOW SLAVE STATUS;<br />
</code></li>
</ul>
<p>
   By specifying the certificate/key file paths in the <strong>CHANGE MASTER TO</strong> command, we&#8217;ve made sure that the slave tries to connect over SSL &#8211; this is important because without this, the slave would send user/pass information <strong>in plain text</strong>. By specifying <strong>REQUIRES SSL</strong> in our master&#8217;s <strong>GRANT</strong> we&#8217;ve ensured that account can only be used if the client provides the correct SSL details. Similarly, by specifying the slave-ip for the slave user, we&#8217;ve further secured the master mysql server.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.fuzzee.co.uk/2009/06/mysql-replication-over-ssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
