<?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>Pass By Value &#187; ssl</title>
	<atom:link href="http://passbyvalue.com/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://passbyvalue.com</link>
	<description>... or is it pass by reference?</description>
	<lastBuildDate>Thu, 26 Jan 2012 03:09:41 +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>SSL setup for Ruby</title>
		<link>http://passbyvalue.com/2008/12/ssl-setup-for-ruby/</link>
		<comments>http://passbyvalue.com/2008/12/ssl-setup-for-ruby/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 11:56:40 +0000</pubDate>
		<dc:creator>Trent</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.passbyvalue.com/?p=37</guid>
		<description><![CDATA[I found recently that I wanted to get SSL enabled when making HTTP connections with Ruby. However, if you&#8217;re wishing to talk to servers that have certificates signed by commercial certificate authorities then you won&#8217;t be able to verify them when you make a connection: require 'net/http' require 'net/https' http = Net::HTTP.new('www.google.com', 443) http.use_ssl = [...]]]></description>
			<content:encoded><![CDATA[<p>I found recently that I wanted to get SSL enabled when making HTTP connections with Ruby.  However, if you&#8217;re wishing to talk to servers that have certificates signed by commercial certificate authorities then you won&#8217;t be able to verify them when you make a connection:</p>
<pre lang="ruby">require 'net/http'
require 'net/https'
http = Net::HTTP.new('www.google.com', 443)
http.use_ssl = true
http.get('/mail')
"warning: peer certificate won't be verified in this SSL session"
=<#net::httpfound 302="" found="" readbody="true"></pre>
<p>Notice line 6? Not good as its really important to be able to verify SSL certificates on the web to make sure that you&#8217;re talking to who you think you&#8217;re talking to!</p>
<p>So to verify these certificates, download commercial certificate authorities used by Mozilla (Firefox) that have been kindly pre-packaged for you:</p>
<p><a href="http://curl.haxx.se/docs/caextract.html">http://curl.haxx.se/docs/caextract.html</a></p>
<p>Store in a logical location:</p>
<pre lang="bash">/usr/share/ssl/cert.pem</pre>
<p>Now, test out that they are working, try this code (IRB works well!):</p>
<pre lang="ruby">require 'net/http'
require 'net/https'
http = Net::HTTP.new('www.google.com', 443)
http.ca_file = '/usr/share/ssl/cacert.pem'
http.use_ssl = true
http.get('/mail')
=<#net::httpfound 302="" found="" readbody="true"></pre>
<p>Yah!  No more warnings, we&#8217;re properly verify the server&#8217;s SSL certificate!</p>
<p>Tip: If you&#8217;re behind a proxy, then you&#8217;ll need to change the third step to be:</p>
<pre lang="ruby">http = Net::HTTP::Proxy('myproxyserver', 8080).new('www.google.com', 443)</pre>
<p>The above code creates a HTTP class with your proxy configuration baked in.  Then you can create an instance from it, just like a regulard HTTP class!</p>
]]></content:encoded>
			<wfw:commentRss>http://passbyvalue.com/2008/12/ssl-setup-for-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

