<?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>California Dreams &#187; Security</title>
	<atom:link href="http://www.heikkitoivonen.net/blog/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heikkitoivonen.net/blog</link>
	<description>A Finn in Silicon Valley - Adventures in Technology</description>
	<lastBuildDate>Wed, 09 Feb 2011 05:57:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>M2Crypto Supports OpenSSL 1.0.x</title>
		<link>http://www.heikkitoivonen.net/blog/2011/01/16/m2crypto-supports-openssl-1-0-x/</link>
		<comments>http://www.heikkitoivonen.net/blog/2011/01/16/m2crypto-supports-openssl-1-0-x/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 05:32:40 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=1149</guid>
		<description><![CDATA[I was supposed to release new M2Crypto version in the summer of 2010 but &#8220;real life&#8221; got in the way, and this extended all the way until this week. I finally decided that I&#8217;d better push out a new release even though there was just one significant change: OpenSSL 1.0.x support. However, I felt this [...]]]></description>
			<content:encoded><![CDATA[<p>I was supposed to release new <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> version in the summer of 2010 but &#8220;real life&#8221; got in the way, and this extended all the way until this week. I finally decided that I&#8217;d better push out a new release even though there was just one significant change: <a href="http://www.openssl.org/">OpenSSL</a> 1.0.x support. However, I felt this was really important since OpenSSL 1.0.x has been out for almost a year now, and it is starting to get difficult to deal with software that does not work with pre-1.0.x.</p>
<p>Unfortunately I made a mistake in my first release to <a href="http://pypi.python.org/pypi/M2Crypto">PyPI</a>: I used the <code>setup.py</code> commands to build, sign and upload a source distribution, but I did this from a tree I had <code>svn export</code>ed. Due to the way the M2Crypto <code>setup.py</code> was constructed this meant that the tarball was lacking vital files. Yesterday I did a new 0.21.1 release from the Subversion checkout, so the tarball now includes everything.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2011/01/16/m2crypto-supports-openssl-1-0-x/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>EV Guidelines Holding Up</title>
		<link>http://www.heikkitoivonen.net/blog/2010/09/14/ev-guidelines-holding-up/</link>
		<comments>http://www.heikkitoivonen.net/blog/2010/09/14/ev-guidelines-holding-up/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 05:09:36 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=1133</guid>
		<description><![CDATA[About a month ago I was reading a post how one can use a browser while disabling all certificates that it ships with. While this can work, it is definitely not for the lazy or someone not very familiar with the issues. The author&#8217;s comment that it was trivial to get an EV certificate with [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago I was reading a post how one can <a href="https://blog.torproject.org/blog/life-without-ca">use a browser while disabling all certificates that it ships with</a>. While this can work, it is definitely not for the lazy or someone not very familiar with the issues. The author&#8217;s comment that it was trivial to get an <a href="http://en.wikipedia.org/wiki/Extended_Validation_Certificate">EV certificate</a> with nothing but email verification got me worried, since this should not have been possible per the EV <a href="http://www.cabforum.org/Guidelines_v1_2.pdf">guidelines</a> (PDF).</p>
<p>I tried to comment, but comments had already been closed. I tried to find the author&#8217;s email address, but could not (in a couple of minutes of searching that I had available), so I filed a bug to Mozilla to track this down. Luckily it turns out the comment is misleading, and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=587355#c3">EV guidelines were followed</a>. Thanks to Kathleen Wilson for tracking down the post author and clarifying things!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2010/09/14/ev-guidelines-holding-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSL in Python 2.7</title>
		<link>http://www.heikkitoivonen.net/blog/2010/08/23/ssl-in-python-2-7/</link>
		<comments>http://www.heikkitoivonen.net/blog/2010/08/23/ssl-in-python-2-7/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 04:20:24 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=1109</guid>
		<description><![CDATA[It has been almost two years since I wrote about the state of SSL in Python 2.6. If you haven&#8217;t read that yet, I suggest you read that first and then continue here, since I will mostly just be talking about things that have changed since then, or things that I have discovered since then. [...]]]></description>
			<content:encoded><![CDATA[<p>It has been almost two years since I wrote about the state of <a href="http://www.heikkitoivonen.net/blog/2008/10/14/ssl-in-python-26/">SSL in Python 2.6</a>. If you haven&#8217;t read that yet, I suggest you read that first and then continue here, since I will mostly just be talking about things that have changed since then, or things that I have discovered since then.</p>
<p>The good news is that things have improved in the stdlib <a href="http://docs.python.org/library/ssl.html">ssl</a> module. The bad news is that it is still missing some critical pieces to make SSL secure. </p>
<p>Python 2.7 enables you to specify ciphers to use explicitly, rather than just relying on what comes default with the SSL version selection. Additionally, if you compile the <code>ssl</code> module with OpenSSL 1.0 and later, using <code>ssl.PROTOCOL_SSLv23</code> is safe (as in, it will not pick the insecure SSLv2 protocol) as long as you don&#8217;t enable SSLv2 specific ciphers (see the ssl module documentation for details).</p>
<h3>Servers</h3>
<p>With that out of the way, there isn&#8217;t really much difference to how you would write a simple SSL server with Python 2.7 compared to what I wrote in 2008. If you know your <code>ssl</code> module was compiled with OpenSSL 1.0 you can pick <code>ssl.PROTOCOL_SSLv23</code> for maximum compatibility. Otherwise you should stick with an explicit version other than v2.</p>
<p>The documentation for the ssl module in 2.7 has improved a lot, and includes good sample code for servers <a href="http://docs.python.org/library/ssl.html#server-side-operation">here</a>.</p>
<p>The <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> code hasn&#8217;t changed. The next M2Crypto release will add support for 0penSSL 1.0.</p>
<h3>Clients</h3>
<p>Checking the peer certificate&#8217;s hostname is still the weak point of the <code>ssl</code> module. The SSL version selection situation has improved slightly like I explained above. Othewise follow the example I wrote in 2008.</p>
<p>Again, the M2Crypto API hasn&#8217;t changed.</p>
<p>Lately I have been working with <a href="http://pycurl.sourceforge.net/">pycurl</a> at <a href="http://egnyte.com/">Egnyte</a>, so I decided to give a client example using that module.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> pycurl
&nbsp;
c = pycurl.<span style="color: black;">Curl</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">URL</span>, <span style="color: #483d8b;">'https://www.google.com'</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">HTTPGET</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">SSL_VERIFYPEER</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">CAINFO</span>, <span style="color: #483d8b;">'ca.pem'</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">SSL_VERIFYHOST</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">try</span>:
    c.<span style="color: black;">perform</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">finally</span>:
    c.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>I am not a big fan of pycurl due to difficulties getting it compiled and the non-Pythonic API. But it is based on the very powerful curl library, so it comes full featured out of the box.</p>
<h3>Other Resources</h3>
<p>Besides the Python crypto libraries capable of doing SSL that I mentioned in my <a href="http://www.heikkitoivonen.net/blog/2008/10/14/ssl-in-python-26/">SSL in Python 2.6</a> article, I have found pycurl. Another find in the Python crypto front is <a href="http://www.cryptlib.com/">cryptlib</a>. </p>
<p><a href="http://www.mikeivanov.com/">Mike Ivanov</a> wrote a great series about crypto in Python: <a href="http://www.activestate.com/blog/2010/03/python-crypto-state-art-part-2">part 2</a>, <a href="http://www.activestate.com/blog/2010/05/python-crypto-state-art-part-3">part 3</a> (link to part 1 seems to have rotted). Mike also produced a <a href="http://mikeivanov.com/pc/python-crypto.pdf">comparison of different Python crypto libraries</a> (PDF).</p>
<p>The future is also looking bright for the <code>ssl</code> module. Already the upcoming <a href="http://docs.python.org/dev/library/ssl.html">Python 3.2 ssl module</a> will include support for <code>SSLContext</code>s so that you can set options for multiple SSL connections at once, allows you to selectively disable SSL versions, and it allows you to check the OpenSSL version as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2010/08/23/ssl-in-python-2-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Secure Password Scheme for Turbogears2 Application with repoze.who and bcrypt</title>
		<link>http://www.heikkitoivonen.net/blog/2009/12/01/secure-password-scheme-for-turbogears2-application-with-repoze-who-and-bcrypt/</link>
		<comments>http://www.heikkitoivonen.net/blog/2009/12/01/secure-password-scheme-for-turbogears2-application-with-repoze-who-and-bcrypt/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 05:04:45 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=985</guid>
		<description><![CDATA[I am working on a little Turbogears2 application, and wanted to use the repoze.who and repoze.what packages that integrate nicely with Turbogears2 and have gathered fair amount of positive feedback. It seems usage is simple, but I was quite disappointed in how password hashes are done by default, especially after I had read Thomas Ptacek&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a little <a href="http://turbogears.org/">Turbogears2</a> application, and wanted to use the <a href="http://pypi.python.org/pypi/repoze.who">repoze.who</a> and <a href="http://pypi.python.org/pypi/repoze.what">repoze.what</a> packages that integrate nicely with Turbogears2 and have gathered fair amount of positive feedback. It seems usage is simple, but I was quite disappointed in how password hashes are done by default, especially after I had read Thomas Ptacek&#8217;s educational rant about <a href="http://chargen.matasano.com/chargen/2007/9/7/enough-with-the-rainbow-tables-what-you-need-to-know-about-s.html">secure password schemes</a>.</p>
<p>It turns out by default the authentication code that gets generated for you if you tell <code>paster quickstart</code> you want authentication is the weak kind of way Thomas warns about. Luckily the correct way he advices is easy to put in by using the <a href="http://pypi.python.org/pypi/bcrypt/">py-bcrypt</a> module. If you want pointers, see <a href="http://bugs.repoze.org/issue85">repoze.who Issue 85</a>, or the <code>py-bcrypt</code> homepage.</p>
<p>Unfortunately <code>py-crypt</code> is kind of annoying to put in dependencies. The pypi entry is named <code>bcrypt</code>, but the download page links to <code>py-bcrypt</code>, so setuptools machinery can not find the right package. This can be worked around relatively easily by adding the<code> py-bcrypt</code> download link to <code>setup.cfg</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>easy_install<span style="">&#93;</span></span>
<span style="color: #000099;">find_links</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> http://www.pylonshq.com/download/</span>
             http://www.mindrot.org/projects/py-bcrypt/
# ...</pre></div></div>

<p>and then in <code>setup.py</code> you do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#...</span>
&nbsp;
install_requires=<span style="color: black;">&#91;</span>
    <span style="color: #483d8b;">&quot;TurboGears2 &gt;= 2.0.3&quot;</span>,
    <span style="color: #483d8b;">&quot;Catwalk &gt;= 2.0.2&quot;</span>,
    <span style="color: #483d8b;">&quot;Babel &gt;=0.9.4&quot;</span>,
    <span style="color: #808080; font-style: italic;">#can be removed iif use_toscawidgets = False</span>
    <span style="color: #483d8b;">&quot;toscawidgets &gt;= 0.9.7.1&quot;</span>,
    <span style="color: #483d8b;">&quot;zope.sqlalchemy &gt;= 0.4 &quot;</span>,
    <span style="color: #483d8b;">&quot;repoze.tm2 &gt;= 1.0a4&quot;</span>,
    <span style="color: #483d8b;">&quot;repoze.what-quickstart &gt;= 1.0&quot;</span>,
<span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">try</span>:
    <span style="color: #ff7700;font-weight:bold;">import</span> bcrypt
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ImportError</span>:
    install_requires.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;py-bcrypt &gt;= 0.1&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
setup<span style="color: black;">&#40;</span>
    install_requires = install_requires,
&nbsp;
<span style="color: #808080; font-style: italic;"># ...</span></pre></div></div>

<p>Now when you go deploy your TG2 app with <code>easy_install </code>or similar tools, it will download the <code>py-bcrypt</code> package the first time, and won&#8217;t bother you if it already exists.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2009/12/01/secure-password-scheme-for-turbogears2-application-with-repoze-who-and-bcrypt/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using M2Crypto with boto &#8211; Secure Access to Amazon Web Services</title>
		<link>http://www.heikkitoivonen.net/blog/2009/10/12/using-m2crypto-with-boto-secure-access-to-amazon-web-services/</link>
		<comments>http://www.heikkitoivonen.net/blog/2009/10/12/using-m2crypto-with-boto-secure-access-to-amazon-web-services/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 01:35:03 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=936</guid>
		<description><![CDATA[Many companies run services in the Amazon cloud infrastructure, so it makes an attractive target for criminals as well. You need to make sure that you really are talking to the right Amazon servers when you use the cloud services. boto seems to have emerged as the winner in the scramble to develop Python libraries [...]]]></description>
			<content:encoded><![CDATA[<p>Many companies run services in the Amazon cloud infrastructure, so it makes an attractive target for criminals as well. You need to make sure that you really are talking to the right Amazon servers when you use the cloud services.</p>
<p><a href="http://code.google.com/p/boto/">boto</a> seems to have emerged as the winner in the scramble to develop Python libraries to deal with <a href="http://aws.amazon.com/">Amazon Web Services</a> (AWS). By default, boto will use the stdlib httplib.HTTPSConnection. This is a problem, because the <a href="http://www.heikkitoivonen.net/blog/2008/10/14/ssl-in-python-26/">stdlib does not provide secure SSL out of the box</a>. However, boto designers have made it easy to plug in alternative SSL implementations that conform to the httplib.HTTPSConnection interface. <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> provides this in <a href="http://www.heikkitoivonen.net/m2crypto/api/M2Crypto.httpslib.HTTPSConnection-class.html">httpslib.HTTPSConnection</a>.</p>
<p>The first step is to <a href="http://www.heikkitoivonen.net/blog/2008/09/30/root-certificates-for-python-programs-using-python/">get CA certificates</a> that we can use to verify that the Amazon servers we will be talking to have valid certificates issued by trusted certificate authorities.</p>
<p>Amazon offers various services that boto provides access to, so the exact details vary a little bit (namely what connection class to instantiate). I&#8217;ll use the SimpleDB as an example, because the first 25 machine hours per month are free so it makes a great test system (you still need to sign up for AWS and provide credit card information).</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> M2Crypto <span style="color: #ff7700;font-weight:bold;">import</span> httpslib, SSL
<span style="color: #ff7700;font-weight:bold;">from</span> boto.<span style="color: black;">sdb</span>.<span style="color: black;">connection</span> <span style="color: #ff7700;font-weight:bold;">import</span> SDBConnection
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> https_connection_factory<span style="color: black;">&#40;</span>host, port=<span style="color: #008000;">None</span>, strict=<span style="color: #ff4500;">0</span>, <span style="color: #66cc66;">**</span>ssl<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;HTTPS connection factory that creates secure connections
    using M2Crypto.&quot;&quot;&quot;</span>
    ctx = SSL.<span style="color: black;">Context</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'tlsv1'</span><span style="color: black;">&#41;</span>
    ctx.<span style="color: black;">set_verify</span><span style="color: black;">&#40;</span>SSL.<span style="color: black;">verify_peer</span> | SSL.<span style="color: black;">verify_fail_if_no_peer_cert</span>, depth=<span style="color: #ff4500;">9</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> ctx.<span style="color: black;">load_verify_locations</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'cacert.pem'</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">1</span>:
        <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">Exception</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'No CA certs'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> httpslib.<span style="color: black;">HTTPSConnection</span><span style="color: black;">&#40;</span>host, port=port, strict=strict,
                                    ssl_context=ctx<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> create_connection<span style="color: black;">&#40;</span>aws_access_key_id, aws_secret_access_key<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Create SimpleDB connection.&quot;&quot;&quot;</span>
    conn = SDBConnection<span style="color: black;">&#40;</span>aws_access_key_id=aws_access_key_id,
                         aws_secret_access_key=aws_secret_access_key,
                         https_connection_factory=<span style="color: black;">&#40;</span>https_connection_factory, <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> conn
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    <span style="color: #808080; font-style: italic;"># Sample usage</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff4500;">3</span>:
        <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Usage: %s aws_access_key_id aws_secret_access_key'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    conn = create_connection<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    domain = conn.<span style="color: black;">create_domain</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'mytest'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        item, key, value = <span style="color: #483d8b;">'item1'</span>, <span style="color: #483d8b;">'key1'</span>, <span style="color: #483d8b;">'value1'</span>    
        domain.<span style="color: black;">put_attributes</span><span style="color: black;">&#40;</span>item, <span style="color: black;">&#123;</span>key: value<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">assert</span> value == domain.<span style="color: black;">get_attributes</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>key<span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">finally</span>:
        conn.<span style="color: black;">delete_domain</span><span style="color: black;">&#40;</span>domain<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Usage:'</span>, conn.<span style="color: black;">get_usage</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The sample application takes your AWS access key and secret access key as parameters, and it assumes <code>cacert.pem</code> file containing the CA certificates is in the same directory. Typically running that application shows that it uses less than 0.006 <s>seconds</s>hours of Amazon computing facilities so you could run this application over <s>15 million</s>4500 times a month without charge.</p>
<p><strong>Update:</strong>I mixed up units, which Mocky pointed out; fixed above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2009/10/12/using-m2crypto-with-boto-secure-access-to-amazon-web-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>M2Crypto 0.20.2 for Ancient OpenSSL</title>
		<link>http://www.heikkitoivonen.net/blog/2009/10/06/m2crypto-0-20-2-for-ancient-openssl/</link>
		<comments>http://www.heikkitoivonen.net/blog/2009/10/06/m2crypto-0-20-2-for-ancient-openssl/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 05:40:20 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=933</guid>
		<description><![CDATA[M2Crypto has been claiming support for OpenSSL 0.9.7 but it actually turned out I wasn&#8217;t testing with quite that old OpenSSL version. Recently M2Crypto got support for RSA PSS stuff, but it turns out this was added in OpenSSL 0.9.7h, and you could not build/run M2Crypto against an older OpenSSL version. Arguably you should not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> has been claiming support for OpenSSL 0.9.7 but it actually turned out I wasn&#8217;t testing with quite that old OpenSSL version. Recently M2Crypto got support for RSA PSS stuff, but it turns out this was added in OpenSSL 0.9.7h, and you could not build/run M2Crypto against an older OpenSSL version. Arguably you should not use those old OpenSSL versions, but apparently there are people who can&#8217;t help it. And since M2Crypto claims support all the way back to 0.9.7 it made sense to make it so.</p>
<p>The M2Crypto trunk and 0.20.2 now omit the RSA PSS stuff if you have too old OpenSSL. Additionally, to prevent this kind of error from happening in the future, I added &#8220;minreq&#8221; (for Minimum Requirements) <a href="http://tinderbox.heikkitoivonen.net/M2Crypto/status.html">Tinderbox</a> client that builds and tests M2Crypto trunk using Python 2.3, OpenSSL 0.9.7 and SWIG 1.3.28 (the current minimum requirements) on Ubuntu 8.04.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2009/10/06/m2crypto-0-20-2-for-ancient-openssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>M2Crypto 0.20.1 Fixes Regression in httpslib.ProxyHTTPSConnection</title>
		<link>http://www.heikkitoivonen.net/blog/2009/08/27/m2crypto-0201-fixes-regression-in-httpslibproxyhttpsconnection/</link>
		<comments>http://www.heikkitoivonen.net/blog/2009/08/27/m2crypto-0201-fixes-regression-in-httpslibproxyhttpsconnection/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 23:38:50 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=896</guid>
		<description><![CDATA[Miloslav Trmac noticed a regression in httpslib.ProxyHTTPSConnection and provided a fix for it, and I&#8217;ve just tagged and uploaded the new 0.20.1 version to PyPI. See the 0.20 release announcement for general information about the 0.20 release series. I&#8217;ve also been getting a few requests for help on building M2Crypto on Fedora Core -based systems, [...]]]></description>
			<content:encoded><![CDATA[<p>Miloslav Trmac noticed a regression in httpslib.ProxyHTTPSConnection and provided a fix for it, and I&#8217;ve just tagged and uploaded the new 0.20.1 version to <a href="http://pypi.python.org/pypi/M2Crypto/">PyPI</a>. See the <a href="http://www.heikkitoivonen.net/blog/2009/08/10/m2crypto-020/">0.20 release announcement</a> for general information about the 0.20 release series.</p>
<p>I&#8217;ve also been getting a few requests for help on building <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> on Fedora Core -based systems, so I&#8217;ve added some info to the <a href="http://chandlerproject.org/Projects/MeTooCrypto#FAQ">FAQ</a>. Basically there is a <code>fedora_setup.sh</code> wrapper script in the source tarball that you can use instead of the plain <code>setup.py</code>. There are more <a href="http://www.heikkitoivonen.net/blog/2009/02/09/m2crypto-build-wrapper-for-fedora-core-based-distributions/">details about  the fedora_setup.sh script</a>, if you are interested.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2009/08/27/m2crypto-0201-fixes-regression-in-httpslibproxyhttpsconnection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>M2Crypto 0.20</title>
		<link>http://www.heikkitoivonen.net/blog/2009/08/10/m2crypto-020/</link>
		<comments>http://www.heikkitoivonen.net/blog/2009/08/10/m2crypto-020/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 05:20:34 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[m2crypto]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=892</guid>
		<description><![CDATA[I am pleased to announce M2Crypto 0.20, which has been in development for over nine months. It fixes over 30 bugs, and fixes and new functionality was contributed by more than ten people. Hooah! The CHANGES file lists the full list of changes, but personally I am most pleased by M2Crypto having reached the magical [...]]]></description>
			<content:encoded><![CDATA[<p>I am pleased to announce <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> 0.20, which has been in development for over nine months. It fixes over 30 bugs, and fixes and new functionality was contributed by more than ten people. Hooah!</p>
<p>The <a href="http://svn.osafoundation.org/m2crypto/tags/0.20/CHANGES">CHANGES</a> file lists the full list of changes, but personally I am most pleased by M2Crypto having reached the magical 80% unit test (code) coverage. Besides that technicality, there are Python 2.6 fixes, threading fixes, added support for RSASSA-PSS signing and verifying, certificates with large serial numbers, and more.</p>
<p><a href="http://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.20.tar.gz#md5=43a4d958a6c892a37ca02ffcc650b66b">Download</a> from pypi.</p>
<p>Or use easy_install (may not work on all systems): easy_install M2Crypto</p>
<blockquote><p>M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers (including AES); SSL functionality to implement clients and servers; HTTPS extensions to Python&#8217;s httplib, urllib, and xmlrpclib; unforgeable HMAC&#8217;ing AuthCookies for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. M2Crypto can also be used to provide SSL for Twisted. Smartcards supported through the Engine API.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2009/08/10/m2crypto-020/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

