<?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>Perfectly Logical Beings &#187; Ruby</title>
	<atom:link href="http://elliot-nelson.net/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliot-nelson.net</link>
	<description>The semi-random rants of a software engineer.</description>
	<lastBuildDate>Fri, 19 Feb 2010 15:39:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thinking Sphinx and Frozen Rails</title>
		<link>http://elliot-nelson.net/2010/02/thinking-sphinx-and-frozen-rails/</link>
		<comments>http://elliot-nelson.net/2010/02/thinking-sphinx-and-frozen-rails/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 15:39:30 +0000</pubDate>
		<dc:creator>Elliot Nelson</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://elliot-nelson.net/?p=64</guid>
		<description><![CDATA[Here&#8217;s the situation: you&#8217;re trying to get the thinking_sphinx gem working with your Rails project on your local machine, and it doesn&#8217;t work.  In fact, when you follow the installation instructions and require &#8220;thinking_sphinx/tasks&#8221; in your Rakefile, you can&#8217;t even run rake anymore.
Running &#8220;rake -T&#8221; nets you the following error:
C:\dev\project&#62;rake -T
(in c:/dev/project)
rake aborted!
undefined method &#8216;map&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the situation: you&#8217;re trying to get the thinking_sphinx gem working with your Rails project on your local machine, and it doesn&#8217;t work.  In fact, when you follow the installation instructions and require &#8220;thinking_sphinx/tasks&#8221; in your Rakefile, you can&#8217;t even run rake anymore.</p>
<p>Running &#8220;rake -T&#8221; nets you the following error:</p>
<blockquote><p>C:\dev\project&gt;rake -T<br />
(in c:/dev/project)<br />
rake aborted!<br />
undefined method &#8216;map&#8217; for nil:NilClass<br />
C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile&#8217;<br />
(See full trace by running task with &#8211;trace)</p></blockquote>
<p>Here is the issue: in order to talk to your database, Thinking Sphinx is loading its own ActiveSupport.  It loads this ActiveSupport from your machine&#8217;s gem list, even if your Rails project is using frozen (vendor) Rails.  <em>If you are getting the error shown above when you attempt to start your server or run rake, it means that your environment.rb specifies a RAILS_GEM_VERSION that is not installed on your machine.</em></p>
<p>Example?  You might have Rails gem versions 2.3.3 and 2.3.5 installed on your machine, but the frozen Rails in your project&#8217;s vendor directory (and thus your project&#8217;s RAILS_GEM_VERSION) is 2.3.4.</p>
<p>Now, it would seem that avoiding this type of scenario is the <em>reason</em> you are freezing Rails, but luckily there&#8217;s an easy fix.  Just install the missing version of the Rails gem, like so:</p>
<blockquote><p>C:\&gt;gem install rails -v 2.3.4</p></blockquote>
<p>Hopefully this saves someone somewhere the headache it gave me.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">(in c:/dev/mobd-fleet)<br />
rake aborted!<br />
undefined method `map&#8217; for nil:NilClass<br />
C:/devtools/ruby/lib/ruby/</p>
<div id=":1yq" class="ii gt">gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile&#8217;<br />
(See full trace by running task with &#8211;trace)</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://elliot-nelson.net/2010/02/thinking-sphinx-and-frozen-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling SSL certificates during SOAP4R calls</title>
		<link>http://elliot-nelson.net/2010/02/handling-ssl-certificates-during-soap4r-calls/</link>
		<comments>http://elliot-nelson.net/2010/02/handling-ssl-certificates-during-soap4r-calls/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 21:59:05 +0000</pubDate>
		<dc:creator>Elliot Nelson</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://elliot-nelson.net/?p=54</guid>
		<description><![CDATA[I ran into a problem recently with a SOAP call that was being made from one of our Ruby applications.  Apparently, something had changed with the SSL certificate at the service endpoint, as we were receiving the following error:
at depth 0 &#8211; 20: unable to get local issuer certificate
OpenSSL::SSL::SSLError: certificate verify failed
Now, nothing had changed [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem recently with a SOAP call that was being made from one of our Ruby applications.  Apparently, something had changed with the SSL certificate at the service endpoint, as we were receiving the following error:</p>
<blockquote><p>at depth 0 &#8211; 20: unable to get local issuer certificate</p>
<p>OpenSSL::SSL::SSLError: certificate verify failed</p></blockquote>
<p>Now, nothing had changed in our code, which was very simple &#8212; all of the details about service location and methods available are in the service&#8217;s WSDL file.  The method that was blowing up simply created the connection to an HTTPS SOAP service and then called a method on the endpoint, like so:</p>
<pre class="brush: ruby;">def status
 # Read WSDL and create driver
 driver = SOAP::WSDLDriverFactory.new(WSDL_URI).create_rpc_driver

 # SOAP headers, basic auth credentials, etc.
 driver.headerhandler &lt;&lt; HeaderHelper.new

 # Make SOAP call
 driver.GetStatus
end</pre>
<p>After doing some research, it was pretty clear that we were getting the error because the certificate being presented by the server was issued by someone that wasn&#8217;t in our trusted store.  More specifically, it was signed using an intermediate certificate (or &#8220;chained&#8221; certificate) that was then linked to a trusted certificate.</p>
<p>There are two ways to fix this problem.  The first way is the fastest, which is a plus if you need to get this issue solved immediately, or you&#8217;re only writing a test wrapper anyway.  Add the following line:</p>
<pre class="brush: ruby; highlight: [5];">def status
 # Read WSDL and create driver
 driver = SOAP::WSDLDriverFactory.new(WSDL_URI).create_rpc_driver

 driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE

 # SOAP headers, basic auth credentials, etc.
 driver.headerhandler &lt;&lt; HeaderHelper.new

 # Make SOAP call
 driver.GetStatus
end</pre>
<p>By setting VERIFY_NONE, you&#8217;re telling the SSL client to ignore the certificate sent by server.  The issue here is that, well, you&#8217;re ignoring the certificate sent by the server.  As any security advocate will tell you, encryption without authentication is no security at all.</p>
<p>The longer, but correct, way to fix this issue is to figure out what intermediate certificates you are missing and then include them in your web application.  This is often as simple as visiting the issuer&#8217;s HTTPS website and examining the certificate chain.  (In Firefox: double-click the lock icon, click View Certificate and then select the Details tab.)</p>
<p>In our case, I was able to do exactly that.  I exported all the certificates below the root cert into the lib folder and added the following lines:</p>
<pre class="brush: ruby; highlight: [5,6];">def status
 # Read WSDL and create driver
 driver = SOAP::WSDLDriverFactory.new(WSDL_URI).create_rpc_driver

 driver.options['protocol.http.ssl_config.ca_file'] = 'lib/signing_cert.pem'
 driver.options['protocol.http.ssl_config.ca_file'] = 'lib/intermed_cert.pem'

 # SOAP headers, basic auth credentials, etc.
 driver.headerhandler &lt;&lt; HeaderHelper.new

 # Make SOAP call
 driver.GetStatus
end</pre>
<p>The call now worked perfectly.  Note that you can set the <em>ca_file</em> option as many times as you need to include multiple certificate files, although generally you should only need one, as typically an issuer will use only one intermediate certificate.</p>
<p>Note that this code doesn&#8217;t do any validation of the server&#8217;s certificate itself.  If you&#8217;d like to do this as well, please check out <a href="http://dev.ctor.org/soap4r/wiki/SslCertificateVerification">this SOAP4R wiki entry</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elliot-nelson.net/2010/02/handling-ssl-certificates-during-soap4r-calls/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
