<?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>Guy Rutenberg &#187; x.509</title>
	<atom:link href="http://www.guyrutenberg.com/tag/x-509/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Extract Public Key from X.509 Certificate as Hex</title>
		<link>http://www.guyrutenberg.com/2009/01/01/extract-public-key-from-x509-certificate-as-hex/</link>
		<comments>http://www.guyrutenberg.com/2009/01/01/extract-public-key-from-x509-certificate-as-hex/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 20:29:04 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[x.509]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=204</guid>
		<description><![CDATA[X.509 certificates are common way to exchange and distribute public key information. For example, most Open Social containers use the OAuth RSA-SHA1 signature method, and distribute their public keys in the X.509 format.
While working on an AppEngine application, I needed to verify requests from such containers. However, there is (currently) no pure python library able [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/X.509">X.509</a> certificates are common way to exchange and distribute public key information. For example, most Open Social containers use the OAuth RSA-SHA1 signature method, and distribute their public keys in the X.509 <a href="https://opensocialresources.appspot.com/certificates">format</a>.</p>
<p>While working on an AppEngine application, I needed to verify requests from such containers. However, there is (currently) no pure python library able of parsing the certificates. This meant that I needed extract the public key out of the certificate manually, and store it in some parsed way inside the Python code.</p>
<p>Fortunately, parsing public keys form a X.509 certificate and representing them as a Hex number turned out simple and easy.<br />
<span id="more-204"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl x509 <span style="color: #660033;">-modulus</span> <span style="color: #660033;">-noout</span> <span style="color: #000000; font-weight: bold;">&lt;</span> pub.cer <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> s<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">Modulus</span>=<span style="color: #000000; font-weight: bold;">/</span>0x<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Just replace pub.cer with the certificate file you want to parse. For example (I&#8217;ve used Orkut&#8217;s certificate):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ openssl x509 -modulus -noout &lt; pub.1199819524.-1556113204990931254.cer | sed s/Modulus=/0x/
0xB1E057678343866DB89D7DEC251899261BF2F5E0D95F5D868F81D600C9A101C9E6DA20606290228308551ED3ACF9921421DCD01EF1DE35DD3275CD4983C7BE0BE325CE8DFC3AF6860F7AB0BF32742CD9FB2FCD1CD1756BBC400B743F73ACEFB45D26694CAF4F26B9765B9F65665245524DE957E8C547C358781FDFB68EC056D1</pre></div></div>

<p>and all I&#8217;ve to do is to copy the result into my Python code (isn&#8217;t Python&#8217;s unbounded integers great?).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/01/01/extract-public-key-from-x509-certificate-as-hex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.403 seconds -->
