<?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>Kabisa Blog &#187; Ariejan de Vroom</title>
	<atom:link href="http://blog.kabisa.nl/author/ariejan/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kabisa.nl</link>
	<description>The Ruby on Rails Experts</description>
	<lastBuildDate>Thu, 17 Jun 2010 11:13:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Handle CMYK colorspace uploads with Paperclip</title>
		<link>http://blog.kabisa.nl/2010/06/17/handle-cmyk-colorspace-uploads-with-paperclip/</link>
		<comments>http://blog.kabisa.nl/2010/06/17/handle-cmyk-colorspace-uploads-with-paperclip/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 11:13:56 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[CMYK]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[RGB]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/?p=148</guid>
		<description><![CDATA[When saving images in general, and JPEG in particular, a colorspace is used. The two most commonly used colorspaces are RGB and CMYK. 
RGB is used for screens (e.g. television, monitors, phones). Screens work by combining different light colors (red, green or blue) into one color we can actually see. 
CMYK is used in print [...]]]></description>
			<content:encoded><![CDATA[<p>When saving images in general, and JPEG in particular, a <em>colorspace</em> is used. The two most commonly used colorspaces are RGB and CMYK. </p>
<p>RGB is used for screens (e.g. television, monitors, phones). Screens work by combining different light colors (red, green or blue) into one color we can actually see. </p>
<p>CMYK is used in print often. Instead of sending out light, paper must reflect light to give it color. If you check your own printer you&#8217;ll see there are three colors: cyan, magenta and yellow. Again, these three colors can be combined to *absorb* colors, and thus reflect the color you want. </p>
<p>The problem is that not all web browsers are capable of handling JPEGs that use the CMYK colorspace. Internet Explorer is the most notorious one. Internet Explorer users will see an &#8216;image not found&#8217;-error &#8211; or red cross &#8211; instead.</p>
<p>If you&#8217;re using <a href="http://github.com/thoughtbot/paperclip">thoughtbot&#8217;s Paperclip</a>, the solution is easy.<br />
By adding some custom ImageMagick `convert` options you can make sure that all generated thumbnails are in the RGB colorspace.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">has_attached_file <span style="color:#ff3333; font-weight:bold;">:avatar</span></pre></div></div>

<p>would become:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">has_attached_file <span style="color:#ff3333; font-weight:bold;">:avatar</span> 
   <span style="color:#ff3333; font-weight:bold;">:convert_options</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:all</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'-strip -colorspace RGB'</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>Easy right? </p>
<p>If you have a lot of CMYK images already, you don&#8217;t have to delete them, you can easily reprocess them when you made the above change:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">User.<span style="color:#9900CC;">find_each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>user<span style="color:#006600; font-weight:bold;">|</span> user.<span style="color:#9900CC;">avatar</span>.<span style="color:#9900CC;">reprocess</span>! <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2010/06/17/handle-cmyk-colorspace-uploads-with-paperclip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dynamic Queue Assignment for Resque Jobs</title>
		<link>http://blog.kabisa.nl/2010/03/16/dynamic-queue-assignment-for-resque-jobs/</link>
		<comments>http://blog.kabisa.nl/2010/03/16/dynamic-queue-assignment-for-resque-jobs/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 14:41:40 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[backgroundrb]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[resque]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/?p=90</guid>
		<description><![CDATA[Resque is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later. Sounds great!
Let&#8217;s dive in directly:

class Archive
  @queue = :file_serve
&#160;
  def self.perform&#40;repo_id, branch = 'master'&#41;
    repo = Repository.find&#40;repo_id&#41;
    repo.create_archive&#40;branch&#41;
  end
end
&#160;
Resque.enqueue&#40;Archive, @repo.id&#41;

This example was taken from the Resque README. [...]]]></description>
			<content:encoded><![CDATA[<p>Resque is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later. Sounds great!</p>
<p>Let&#8217;s dive in directly:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Archive
  <span style="color:#0066ff; font-weight:bold;">@queue</span> = <span style="color:#ff3333; font-weight:bold;">:file_serve</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">perform</span><span style="color:#006600; font-weight:bold;">&#40;</span>repo_id, branch = <span style="color:#996600;">'master'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    repo = Repository.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>repo_id<span style="color:#006600; font-weight:bold;">&#41;</span>
    repo.<span style="color:#9900CC;">create_archive</span><span style="color:#006600; font-weight:bold;">&#40;</span>branch<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
Resque.<span style="color:#9900CC;">enqueue</span><span style="color:#006600; font-weight:bold;">&#40;</span>Archive, <span style="color:#0066ff; font-weight:bold;">@repo</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>This example was taken from the Resque README. It works great, but there&#8217;s a problem: you hard-code the queue to use. For an app I&#8217;m currently working on this is unwanted behaviour.<br />
<span id="more-90"></span><br />
So, how do you make Resque pick the right queue based on the data you feed it?</p>
<p>In the following example I&#8217;ll show you how to pick the right queue based on the user that requests the job.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> StreamWorker  
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">enqueue</span><span style="color:#006600; font-weight:bold;">&#40;</span>resource<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#6666ff; font-weight:bold;">Resque::Job</span>.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>select_queue<span style="color:#006600; font-weight:bold;">&#40;</span>resource<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF; font-weight:bold;">self</span>, resource.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>    
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">select_queue</span><span style="color:#006600; font-weight:bold;">&#40;</span>resource<span style="color:#006600; font-weight:bold;">&#41;</span>
    resource.<span style="color:#9900CC;">user</span>.<span style="color:#9900CC;">use_priority_queue</span>? ? <span style="color:#ff3333; font-weight:bold;">:stream_high</span> : <span style="color:#ff3333; font-weight:bold;">:stream_low</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">perform</span><span style="color:#006600; font-weight:bold;">&#40;</span>resource_id<span style="color:#006600; font-weight:bold;">&#41;</span>
    resource = Resource.<span style="color:#9900CC;">find_by_id</span><span style="color:#006600; font-weight:bold;">&#40;</span>resource_id<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#9966CC; font-weight:bold;">if</span> resource.<span style="color:#0000FF; font-weight:bold;">nil</span>?
    resource.<span style="color:#9900CC;">process</span>!
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Instead of using Resque&#8217;s convenience method <code>Resque.enqueue</code> we create a <code>Resque::Job</code> ourselves. The <code>select_queue</code> determines which queue is used. </p>
<p>Creating a <code>StreamWorker</code> job in the right queue is as easy as running:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">StreamWorker.<span style="color:#9900CC;">enqueue</span><span style="color:#006600; font-weight:bold;">&#40;</span>@resource<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>In case you&#8217;re wondering, the <code>User#use_priority_queue?</code> method returns a boolean based on the role the user has.</p>
<p>Happy queueing!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2010/03/16/dynamic-queue-assignment-for-resque-jobs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup a self-signed SSL site with Apache2</title>
		<link>http://blog.kabisa.nl/2010/03/08/setup-a-self-signed-ssl-site-with-apache2/</link>
		<comments>http://blog.kabisa.nl/2010/03/08/setup-a-self-signed-ssl-site-with-apache2/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 15:23:48 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/2010/03/08/setup-a-self-signed-ssl-site-with-apache2/</guid>
		<description><![CDATA[Some things need to be secure. Login and registration pages are often among them. This guide will show you how to quickly set-up a SSL site with a self-signed certificate and automatic HTTP-to-HTTPS redirect. This is ideal for setting up staging environments.
I&#8217;ll assume you have a standard Debian system with the apache2 package installed and [...]]]></description>
			<content:encoded><![CDATA[<p>Some things need to be secure. Login and registration pages are often among them. This guide will show you how to quickly set-up a SSL site with a self-signed certificate and automatic HTTP-to-HTTPS redirect. This is ideal for setting up staging environments.</p>
<p>I&#8217;ll assume you have a standard Debian system with the apache2 package installed and ready.</p>
<p>The first step is to generate a key. You must choose a passphrase here. We&#8217;ll remove that later on for easier Apache2 restarts</p>
<pre>openssl genrsa -des3 -out server.key 4096</pre>
<p>Next, you need to generate a <em>Certificate Sign Request</em> or CSR. Some things to consider:</p>
<ul>
<li>Enter the <em>Fully Qualified Domain Name</em> in the <em>Common Name</em> field. For this blog that&#8217;d be &#8216;blog.kabisa.nl&#8217;.</li>
<li>There&#8217;s no need to set a <em>challenge password</em>.</li>
</ul>
<pre>openssl req -new -key server.key -out server.csr</pre>
<p>Next, sign the request with your key.</p>
<pre>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</pre>
<p>Then, create an insecure version of your key. This will remove the pass phrase. If you don&#8217;t do this apache will ask for the pass phrase when it loads the key.</p>
<pre>openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key</pre>
<p>A good place to keep your key and certificate is <code>/etc/apache2/ssl</code>. Make sure you chmod 600 it for the root user.</p>
<p>Okay, setup your VirtualHosts. This example is for a Passenger-powered example app.</p>
<pre>&lt;VirtualHost *:80&gt;
  ServerName example.com

  Redirect permanent / https://example.com/
&lt;/VirtualHost&gt;

&lt;VirtualHost *:443&gt;
  ServerAdmin support@example.com
  ServerName example.com

  # SSL Engine Switch
  SSLEngine on

  # SSL Cipher Suite:
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

  # Server Certificate
  SSLCertificateFile /etc/apache2/ssl/server.crt

  # Server Private Key
  SSLCertificateKeyFile /etc/apache2/ssl/server.key

  # Set header to indentify https requests for Mongrel
  RequestHeader set X-Forwarded-Proto "https"

  BrowserMatch ".*MSIE.*" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0

  DocumentRoot /var/rails/example/current/public
  &lt;Directory "/var/rails/example/current/public"&gt;
    AllowOverride all
    Allow from all
    Options -MultiViews
  &lt;/Directory&gt;
 &lt;/VirtualHost&gt;</pre>
<p>There is a file name <code>/etc/apache2/ports.conf</code> that configures which ports apache listen on. Make it look like this:</p>
<pre>NameVirtualHost *:80
Listen 80

&lt;IfModule mod_ssl.c&gt;
    NameVirtualHost *:443
    Listen 443
&lt;/IfModule&gt;</pre>
<p>All set. Now restart apache2 and you should be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2010/03/08/setup-a-self-signed-ssl-site-with-apache2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Presentation: Heroku &amp; Jeweler + Gemcutter</title>
		<link>http://blog.kabisa.nl/2009/12/11/presentation-heroku-jeweler-gemcutter/</link>
		<comments>http://blog.kabisa.nl/2009/12/11/presentation-heroku-jeweler-gemcutter/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 09:02:11 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[gemcutter]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[jeweler]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/?p=49</guid>
		<description><![CDATA[A small presentation by Ariejan on two topics:

Heroku &#8211; What is Heroku and how does it compare to Amazon EC2 and Kabisa&#8217;s Hosting
Jeweler + Gemcutter &#8211; How to use Jeweler to manage your gem and push it to gemcutter


Heroku + Jeweler &#38; Gemcutter
View more presentations from Ariejan de Vroom.

Ariejan and other Kabisa people are available [...]]]></description>
			<content:encoded><![CDATA[<p>A small presentation by Ariejan on two topics:</p>
<ul>
<li><strong>Heroku</strong> &#8211; What is Heroku and how does it compare to Amazon EC2 and Kabisa&#8217;s Hosting</li>
<li><strong>Jeweler + Gemcutter</strong> &#8211; How to use Jeweler to manage your gem and push it to gemcutter</li>
</ul>
<p><span id="more-49"></span></p>
<div style="width:425px;text-align:left" id="__ss_2673831"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/ariejan/heroku-jeweler-gemcutter" title="Heroku + Jeweler &amp; Gemcutter">Heroku + Jeweler &amp; Gemcutter</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=kks-20091208-091208082843-phpapp02&#038;stripped_title=heroku-jeweler-gemcutter" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=kks-20091208-091208082843-phpapp02&#038;stripped_title=heroku-jeweler-gemcutter" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/ariejan">Ariejan de Vroom</a>.</div>
</div>
<p><em>Ariejan and other Kabisa people are available for private and public talks! Mail to <a href="mailto:info@kabisa.nl">info at kabisa.nl</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2009/12/11/presentation-heroku-jeweler-gemcutter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen: How to fix &#8220;SIOCSIFADDR: No such device&#8221;</title>
		<link>http://blog.kabisa.nl/2009/12/11/xen-how-to-fix-siocsifaddr-no-such-device/</link>
		<comments>http://blog.kabisa.nl/2009/12/11/xen-how-to-fix-siocsifaddr-no-such-device/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 08:54:38 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[eth0]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/?p=47</guid>
		<description><![CDATA[Yesterday I had to clone a VPS to run some CPU and memory intensive tests. With our current setup (Xen + LVM), cloning an image on the fly is easy. 
After configuring a new IP address for the clone, I booted up the system. Nice, but I ran into a problem:
Configuring network interfaces...SIOCSIFADDR: No such [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had to clone a VPS to run some CPU and memory intensive tests. With our current setup (Xen + LVM), cloning an image on the fly is easy. </p>
<p>After configuring a new IP address for the clone, I booted up the system. Nice, but I ran into a problem:</p>
<pre>Configuring network interfaces...SIOCSIFADDR: No such device
eth0: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
SIOCSIFBRDADDR: No such device
eth0: ERROR while getting interface flags: No such device
eth0: ERROR while getting interface flags: No such device
Failed to bring up eth0.</pre>
<p>After some investigation I found that the MAC address for eth0 is stored on disk in <code>/etc/udev/rules.d/z25_persistent-net.rules</code>. That makes sense, because the whole file system was cloned. But, I swapped the virtual network card, and I&#8217;d expect is to work. It didn&#8217;t. </p>
<p>The solution is quite easy. Empty <code>/etc/udev/rules.d/z25_persistent-net.rules</code>. Then shutdown and start your VPS. You must do a full shutdown, a reboot won&#8217;t work. </p>
<p>For the lazy folk out there, here&#8217;s how to quickly empty the file:</p>
<pre>echo "" > /etc/udev/rules.d/z25_persistent-net.rules</pre>
<p>After you have started your VPS back up again, you should be able to ping out over the network. If you peek in <code>/etc/udev/rules.d/z25_persistent-net.rules</code> you should see a line that contains the MAC address for your virtual network device.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2009/12/11/xen-how-to-fix-siocsifaddr-no-such-device/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby and SSL Certificate Validation</title>
		<link>http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/</link>
		<comments>http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:35:38 +0000</pubDate>
		<dc:creator>Ariejan de Vroom</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.kabisa.nl/?p=31</guid>
		<description><![CDATA[If your ruby app is doing SSL, you have probably seen one of the following errors:
doc = Hpricot(open("https://www.cert.org/blogs/vuls/rss.xml")) # => /usr/lib/ruby/1.8/net/http.rb:590:in `connect': certificate verify failed (OpenSSL::SSL::SSLError)
or
warning: peer certificate won't be verified in this SSL session
The solution is to make sure ruby has access to the right set of root certificates.

The easiest way to get hold [...]]]></description>
			<content:encoded><![CDATA[<p>If your ruby app is doing SSL, you have probably seen one of the following errors:</p>
<p><code>doc = Hpricot(open("https://www.cert.org/blogs/vuls/rss.xml")) # => /usr/lib/ruby/1.8/net/http.rb:590:in `connect': certificate verify failed (OpenSSL::SSL::SSLError)</code></p>
<p>or</p>
<p><code>warning: peer certificate won't be verified in this SSL session</code></p>
<p>The solution is to make sure ruby has access to the right set of root certificates.<br />
<span id="more-31"></span><br />
The easiest way to get hold of those root certificates is by downloading this file <a href="http://curl.haxx.se/ca/cacert.pem">cacert.pem</a> (<a href="http://curl.haxx.se/docs/caextract.html">details</a>) (updated weekly by the developers of CURL, based on the Mozilla browser). Download this file and store it somewhere in your app. </p>
<p>If you&#8217;re really keen on security, don&#8217;t trust the guys from CURL and download the different root certificates from their providers manually. However, in most cases, the file from CURL will suffice.</p>
<p>Then, in your ruby code, setup the connection like this and you&#8217;ll have a validated SSL connection:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#! /usr/bin/env ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/https'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'uri'</span>
&nbsp;
uri = <span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'https://localhost/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
http = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">host</span>, uri.<span style="color:#9900CC;">port</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">if</span> uri.<span style="color:#9900CC;">scheme</span> == <span style="color:#996600;">&quot;https&quot;</span>  <span style="color:#008000; font-style:italic;"># enable SSL/TLS</span>
  http.<span style="color:#9900CC;">use_ssl</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
  <span style="color:#008000; font-style:italic;"># Only needed for ruby 1.8.6</span>
  <span style="color:#008000; font-style:italic;"># http.enable_post_connection_check = true</span>
  http.<span style="color:#9900CC;">verify_mode</span> = <span style="color:#6666ff; font-weight:bold;">OpenSSL::SSL::VERIFY_PEER</span>
  http.<span style="color:#9900CC;">ca_file</span> = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">&quot;cacert.pem&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
http.<span style="color:#9900CC;">start</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
  http.<span style="color:#9900CC;">request_get</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">path</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>res<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#CC0066; font-weight:bold;">print</span> res.<span style="color:#9900CC;">body</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
