<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Ruby and SSL Certificate Validation</title>
	<atom:link href="http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/</link>
	<description>The Ruby on Rails Experts</description>
	<lastBuildDate>Sat, 03 Jul 2010 14:41:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ariejan</title>
		<link>http://blog.kabisa.nl/2009/12/04/ruby-and-ssl-certificate-validation/comment-page-1/#comment-10</link>
		<dc:creator>Ariejan</dc:creator>
		<pubDate>Fri, 04 Dec 2009 14:54:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.kabisa.nl/?p=31#comment-10</guid>
		<description>In a recent Rails 2.3.5 and Ruby 1.8.7 project, I monkey-patched Net:HTTP in environment.rb (maybe it can be moved to a separate initializer). 

I put the cacert.pem file in the config directory.

&lt;pre lang=&quot;ruby&quot;&gt;class Net::HTTP
  alias_method :old_initialize, :initialize
  def initialize(*args)
    old_initialize(*args)
    @ssl_context = OpenSSL::SSL::SSLContext.new
    @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
    @ssl_context.ca_file = File.join(RAILS_ROOT, &#039;config&#039;, &#039;cacert.pem&#039;)
  end
end&lt;/pre&gt;

Whenever SSL is used, the cacert.pem file is loaded. Awesome!</description>
		<content:encoded><![CDATA[<p>In a recent Rails 2.3.5 and Ruby 1.8.7 project, I monkey-patched Net:HTTP in environment.rb (maybe it can be moved to a separate initializer). </p>
<p>I put the cacert.pem file in the config directory.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>
  alias_method <span style="color:#ff3333; font-weight:bold;">:old_initialize</span>, <span style="color:#ff3333; font-weight:bold;">:initialize</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    old_initialize<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@ssl_context</span> = <span style="color:#6666ff; font-weight:bold;">OpenSSL::SSL::SSLContext</span>.<span style="color:#9900CC;">new</span>
    <span style="color:#0066ff; font-weight:bold;">@ssl_context</span>.<span style="color:#9900CC;">verify_mode</span> = <span style="color:#6666ff; font-weight:bold;">OpenSSL::SSL::VERIFY_PEER</span>
    <span style="color:#0066ff; font-weight:bold;">@ssl_context</span>.<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>RAILS_ROOT, <span style="color:#996600;">'config'</span>, <span style="color:#996600;">'cacert.pem'</span><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></pre></div></div>

<p>Whenever SSL is used, the cacert.pem file is loaded. Awesome!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
