<?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"
	>

<channel>
	<title>California Dreams</title>
	<atom:link href="http://www.heikkitoivonen.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heikkitoivonen.net/blog</link>
	<description>A Finn in Silicon Valley - Adventures in Technology</description>
	<pubDate>Wed, 08 Oct 2008 06:11:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Office Resource Finder</title>
		<link>http://www.heikkitoivonen.net/blog/2008/10/07/office-resource-finder/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/10/07/office-resource-finder/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 06:11:28 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=348</guid>
		<description><![CDATA[Have you ever been looking for a colleague, printer, or just about any resource in an office and being frustrated there was no map showing you where to go? I have good news for you. I just released Solu, which is a &#8220;Self-service Office resource Locator and Updater&#8221;. Or &#8220;cubicle finder&#8221;. Or whatever you want [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been looking for a colleague, printer, or just about any resource in an office and being frustrated there was no map showing you where to go? I have good news for you. I just released <a href="http://www.heikkitoivonen.net/solu/">Solu</a>, which is a &#8220;Self-service Office resource Locator and Updater&#8221;. Or &#8220;cubicle finder&#8221;. Or whatever you want to call it.</p>
<p>This project started as a perfect example of &#8220;scratch your own itch&#8221;. I was doing some research on how to do REST with Python, and remembered <a href="http://jjinux.blogspot.com/2008/04/python-werkzeug.html">jj recommended Werkzeug</a> at some point, so I took a look. Around the same time I was chatting with our new admin, and noticed the office blueprints on the IT cubicle wall. This lead the two us discussing how nice it would be if there was a map to help us new people around. I ended up saying I could program such a system in 20 hours.</p>
<p>So I ended doing a bit more than research, and studied <a href="http://werkzeug.pocoo.org/">Werkzeug</a> and <a href="http://jquery.com/">jQuery</a>. And although it wasn&#8217;t strictly necessary I also spent quite a bit of time researching how to make an easy to deploy package of the application, and how to make it easy to try it out. In the end I spent almost exactly 20 hours on the first version, but I realized I could have done it in about half the time had I used <a href="http://pylonshq.com/">Pylons</a>, mostly because I already knew Pylons and also because the things were I struggled with Werkzeug were already provided by Pylons, or easily integrated into Pylons. After the initial version I&#8217;ve spent another 20 hours to fix bugs, write tests, and in general getting it to a stage I felt good to release. Even still it is missing some pieces I know how to do in Pylons, but still don&#8217;t know for sure how to deal with them in Werkzeug.</p>
<p>Since I developed this application partially on <a href="http://www.spikesource.com/">SpikeSource</a> time, it was nice of them to let me Open Source it to everyone&#8217;s benefit.</p>
<p>Some of the things I really enjoyed about Werkzeug include:</p>
<ul>
<li>Interactive Python debugger in the browser</li>
<li>Small enough to make the ramp up period quick</li>
<li>Good documentation</li>
<li>Enough features to provide almost everything I needed</li>
<li>Easy to swap template system from Jinja to <a href="http://www.makotemplates.org/">Mako</a> (since I didn&#8217;t want to spend the time to learn Jinja too)</li>
<li>Writing tests was easy</li>
<li>Easy to work with Unicode</li>
<li>Great tutorial which fit my needs almost perfectly</li>
</ul>
<p>Some of the things I found frustrating about Werkzeug:</p>
<ul>
<li>No builtin mechanism to load application options from a file</li>
<li>No help to package the application</li>
<li>No cross-site request forgery (<a href="http://en.wikipedia.org/wiki/Csrf">CSRF</a>) protection out of the box</li>
<li>No internationalization/localization (i18n/l10n) support out of the box</li>
<li>No samples or recommendations on how to pass application and options to views and templates</li>
<li>No samples or recommendations on how to implement sessions</li>
</ul>
<p>In the end I used <a href="http://www.voidspace.org.uk/python/configobj.html">ConfigObj</a> to load the options from an ini file. This was a little trickier than I thought at first because I wanted the manage script to work so that I could run with Werkzeug&#8217;s server while testing, but I also wanted to retain <a href="http://wsgi.org/">WSGI</a> deployment possibility. Packaging took some extra reading about setuptools. CSRF is still a little open, although I got pointers to zine.utils.forms and also found werkzeug.contrib.sessions which should make it possible in the way I was thinking about it. I don&#8217;t see CSRF as a huge issue at this point, though, given the data this application handles. I also got some pointers on how to implement get_app() function to get the application object from anywhere, so getting the options stored in the app became easy. I still have some open questions about localization, but those might go away once I actually try to do that.</p>
<p>There are some obvious improvements to Solu, like fixing the CSRF issues, i18n/l10n, multiple and resizeable maps, dealing with errors in a more user-friendly way, and overall making it pretty. I could see someone wanting to pull the information from company LDAP database or some such, and hooking this up with general employee database.</p>
<p>Since I spent so much time making it easy to see what the application is about by providing a <a href="http://www.heikkitoivonen.net/solu/">website with screenshot</a>s, a <a href="http://soludemo.heikkitoivonen.net/">demo site</a>, easy installation and <a href="http://pypi.python.org/pypi/solu/">instructions</a> on how to run your own application, I am interested in hearing how I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/10/07/office-resource-finder/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Released M2Crypto 0.19</title>
		<link>http://www.heikkitoivonen.net/blog/2008/10/05/released-m2crypto-019/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/10/05/released-m2crypto-019/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 05:01:56 +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=342</guid>
		<description><![CDATA[I just pushed out M2Crypto 0.19. This ends the longest hiatus in releases (almost a year since 0.18.2) since I took over the project; apologies for the delays. I highlighted the best parts about 0.19 in an earlier post, so I won&#8217;t repeat them here. I need to make one clarification regarding Python 2.6 support: [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed out <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> 0.19. This ends the longest hiatus in releases (almost a year since 0.18.2) since I took over the project; apologies for the delays. I <a href="http://www.heikkitoivonen.net/blog/2008/09/17/countdown-to-m2crypto-019-begins/">highlighted</a> the best parts about 0.19 in an earlier post, so I won&#8217;t repeat them here. I need to make one clarification regarding Python 2.6 support: the optional timeout parameter added to many network modules is not yet supported in M2Crypto 0.19. I just noticed this too late for this release.</p>
<p>In preparation for 0.19 I did the first ever code coverage analysis of M2Crypto. I installed the latest <a href="http://nedbatchelder.com/code/modules/coverage.html">coverage</a> and <a href="http://nedbatchelder.com/code/modules/coverage.html">nose</a>, and run the M2Crypto unit tests. At first I got 72%. I then added some tests on trunk, and got the number to 75%. Then I added some docstrings and was surprised to note the figure jumped to 78%. Now I just need to write some more docstrings to break the magical 80% code coverage limit <img src='http://www.heikkitoivonen.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>While nose and coverage were surprisingly easy to set up and run, finding out the specific lines of code that were not covered was not very user friendly. For that I installed <a href="http://darcs.idyll.org/~t/projects/figleaf/README.html">figleaf</a>. The workflow then became:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">nosetests --with-coverage --cover-package=M2Crypto</pre></div></div>

<p>which wrote the file <code>.figleaf</code> in the current directory. Then I run:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">figleaf2html -d build/fig .figleaf</pre></div></div>

<p>which produced HTML files in the <code>build/fig</code> directory. The HTML files showed the source code, formatted such that it was easy to see what was covered and what not. Basically non-covered lines were colored red.</p>
<p><strong>Update:</strong> It seems I messed up the figleaf instructions. The above nosetests line will not produce .figleaf. I know of two ways to produce that. The first one is to add two more options to the nosetests command, which then becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">nosetests --with-coverage --cover-package=M2Crypto --with-figleafsections --figleaf-file=.figleaf</pre></div></div>

<p>Unfortunately trying to process this with <code>figleaf2html</code> leads into:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">Traceback <span style="color: black;">&#40;</span>most recent call last<span style="color: black;">&#41;</span>:
  File <span style="color: #483d8b;">&quot;/usr/bin/figleaf2html&quot;</span>, line <span style="color: #ff4500;">8</span>, <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #66cc66;">&lt;</span>module<span style="color: #66cc66;">&gt;</span>
    load_entry_point<span style="color: black;">&#40;</span><span style="color: #483d8b;">'figleaf==0.6.1'</span>, <span style="color: #483d8b;">'console_scripts'</span>, <span style="color: #483d8b;">'figleaf2html'</span><span style="color: black;">&#41;</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  File <span style="color: #483d8b;">&quot;/usr/lib/python2.5/site-packages/figleaf-0.6.1-py2.5.egg/figleaf/annotate_html.py&quot;</span>, line <span style="color: #ff4500;">256</span>, <span style="color: #ff7700;font-weight:bold;">in</span> main
    coverage = figleaf.<span style="color: black;">combine_coverage</span><span style="color: black;">&#40;</span>coverage, d<span style="color: black;">&#41;</span>
  File <span style="color: #483d8b;">&quot;/usr/lib/python2.5/site-packages/figleaf-0.6.1-py2.5.egg/figleaf/__init__.py&quot;</span>, line <span style="color: #ff4500;">89</span>, <span style="color: #ff7700;font-weight:bold;">in</span> combine_coverage
    keys.<span style="color: black;">update</span><span style="color: black;">&#40;</span><span style="color: #008000;">set</span><span style="color: black;">&#40;</span>d2.<span style="color: black;">keys</span><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: #008000;">AttributeError</span>: CodeTracer instance has no attribute <span style="color: #483d8b;">'keys'</span></pre></div></div>

<p>The second way which actually works is to use figleaf directly:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">figleaf --ignore-pylibs setup.py test -q</pre></div></div>

<p>in the M2Crypto source tree. Then <code>figleaf2html</code> will work. The downside is that <code>setup.py</code> and test files are included in coverage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/10/05/released-m2crypto-019/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Protocol Testing with Doctests</title>
		<link>http://www.heikkitoivonen.net/blog/2008/10/04/protocol-testing-with-doctests/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/10/04/protocol-testing-with-doctests/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 03:47:34 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=305</guid>
		<description><![CDATA[A couple of years ago I was asked to write some tests (and maybe test framework, I can&#8217;t remember) for Cosmo, the Chandler Server. I think the only tools we had used for testing until then were litmus and manual testing, maybe with some unit tests. The protocols to be tested include ticket, CMP etc. [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago I was asked to write some tests (and maybe test framework, I can&#8217;t remember) for <a href="http://chandlerproject.org/Projects/CosmoHome">Cosmo</a>, the Chandler Server. I think the only tools we had used for testing until then were <a href="http://www.webdav.org/neon/litmus/">litmus</a> and manual testing, maybe with some unit tests. The protocols to be tested include <a href="http://chandlerproject.org/Projects/CosmoTickets">ticket</a>, <a href="http://chandlerproject.org/bin/view/Projects/CosmoManagementProtocol">CMP</a> etc. protocols.</p>
<p>The thought of expanding litmus, which was a tool written in C, did not sound too promising. Command line tool to test the protocol was also what we were mainly after at that point, so GUI tools were not needed. And it was going to be easier to automate command line tools with <a href="http://en.wikipedia.org/wiki/Tinderbox_(software)">Tinderbox</a>.</p>
<p>Around that time I had been really sold on <a href="http://docs.python.org/library/doctest.html">doctests</a>, so I figured by writing some helper functions the protocol tests for Cosmo could be done easily as Python doctests. Developing the &#8220;framework&#8221; was fast, I was testing within minutes, and probably the time spent on the helper functions still amounts to less than a day, total. I based the helper functions on <a href="http://docs.python.org/library/httplib.html">httplib</a>, but <a href="http://docs.python.org/library/urllib2.html">urllib2</a> or <a href="http://code.google.com/p/httplib2/">httplib2</a> would probably make the experience even easier. I named the tool &#8220;<a href="http://svn.osafoundation.org/server/cosmo/trunk/cosmo/src/test/functional/silmut/">silmut</a>&#8221; , which is an anagram of litmus, and also a word in the Finnish language, meaning &#8220;buds&#8221;.</p>
<p>In the end we collected each protocol&#8217;s tests into its own file. At the top we had some code to do common initialization, and after that followed the actual tests. Here&#8217;s an example of a test:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">View account
&nbsp;
    <span style="color: #66cc66;">&gt;&gt;&gt;</span> r = request<span style="color: black;">&#40;</span><span style="color: #483d8b;">'GET'</span>, <span style="color: #483d8b;">'%s/cmp/user/%s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>path, user1<span style="color: black;">&#41;</span>, headers=authHeaders<span style="color: black;">&#41;</span>
    <span style="color: #66cc66;">&gt;&gt;&gt;</span> r.<span style="color: black;">status</span> <span style="color: #808080; font-style: italic;"># GET account ok</span>
    <span style="color: #ff4500;">200</span></pre></div></div>

<p>I was actually surprised to note that these tests are still in the Cosmo sources, and apparently being maintained. Just goes to show you don&#8217;t always need to be too fancy to get the job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/10/04/protocol-testing-with-doctests/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Common SSL Misconceptions</title>
		<link>http://www.heikkitoivonen.net/blog/2008/10/03/common-ssl-misconceptions/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/10/03/common-ssl-misconceptions/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 05:36:23 +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=329</guid>
		<description><![CDATA[There seems to be a single fundamental misunderstanding about Secure Sockets Layer (SSL), or Transport Layer Security (TLS) as the newer standard is called, and that is that given insecure DNS, it is possible to perform a man-in-the-middle attack on any SSL connection. Obviously if this was true, SSL would not be used, so that [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be a single fundamental misunderstanding about Secure Sockets Layer (SSL), or <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">Transport Layer Security</a> (TLS) as the newer standard is called, and that is that given insecure <a href="http://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>, it is possible to perform a <a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack">man-in-the-middle attack</a> on any SSL connection. Obviously if this was true, SSL would not be used, so that should immediately make you suspicious.</p>
<p>There are  many <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security#Security">checks</a> that an SSL implementation must do. Typically SSL libraries will do these checks without application developers needing to worry about them too much. These checks prevent many classes of hacking attempts, for example by foiling tools that automatically create certificates by duplicating all human readable fields for connections they try to spoof, because these generated certificates are not issued by known certificate authorities. But what often seems to be missing by default, and is also often omitted by literary describing SSL deployment is the post connection check done right after the SSL handshake. Typically this check is to make sure that you connected with the host you wanted to connect, and is done by checking the hostname field of the certificate returned by the peer. (There are other kinds of checks that could be done too, like verifying the peer&#8217;s certificate fingerprint is in an expected set of fingerprints.) Without this check it would be possible to to perform a MITM attack by requesting a valid certificate from a certificate authority for any domain, and use that to spoof connection to any domain.</p>
<p>There is also some confusion about HTML pages that submit data to a secure URL, or secured page that submits data to non-secure URL. In both of these cases it is possible to attack the unsecured connections, rendering SSL useless. Unfortunately many banks and ecommerce sites <a href="http://www.cs.biu.ac.il/~herzbea//shame/index.html">still</a> use these techniques. There are a couple of workarounds for end users regarding these: one is to just try and submit the login page without any data, which in some cases leads to SSL-protected version of the page. Also in some cases you can try changing the http protocol to https manually in the urlbar. And if you have ever encountered a secured login page, it would be a good idea to bookmark the page for future use (rather than try to remember type the url or worse follow a link from some page).</p>
<p>It should be noted that given massive DNS vulnerabilities like what Dan Kaminsky found (let&#8217;s hope there aren&#8217;t more lurking around), it is possible to attack even SSL protected sites, because the attackers can get domain validated certificates for any domain. Only sites serving <a href="/blog/2008/08/23/ev-certificate-sites-still-vulnerable-to-dns-hacks/">pure</a> EV content would be safe from tampering, but even then this requires users to use products that support EV and be aware that the site is supposed to be EV protected (and stop if the site comes up without EV indicators).</p>
<p><strong>Update:</strong> Dan Kaminsky pointed out in a comment that even an EV site can be attacked by script in another window (assuming the attacker redirected the other window into a domain validated site with same URL as the EV site), so one additional condition needs to be tacked on to ensure security: the browser should have just one window open, on the pure EV site. It could be relaxed a little by saying all browser windows and tabs must be on pure EV sites.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/10/03/common-ssl-misconceptions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Replace Python&#8217;s socket.ssl with M2Crypto&#8217;s SSL Implementation</title>
		<link>http://www.heikkitoivonen.net/blog/2008/10/01/how-to-replace-pythons-socketssl-with-m2cryptos-ssl-implementation/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/10/01/how-to-replace-pythons-socketssl-with-m2cryptos-ssl-implementation/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 02:06:42 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Security]]></category>

		<category><![CDATA[m2crypto]]></category>

		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=315</guid>
		<description><![CDATA[It seems like I started a mini-series about &#8220;hidden&#8221; M2Crypto tools and modules&#8230;
Python&#8217;s socket.ssl is not secure. If you need any real security you need to look for 3rd party packages (things will improve a little with Python 2.6).
Sometimes you are faced with a library that does SSL, but uses Python&#8217;s socket.ssl that you can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>It seems like I <a href="/blog/2008/09/30/root-certificates-for-python-programs-using-python/">started</a> a mini-series about &#8220;hidden&#8221; <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> tools and modules&#8230;</p>
<p>Python&#8217;s socket.ssl is not secure. If you need any real security you need to look for 3rd party packages (things will <a href="http://docs.python.org/dev/library/ssl.html">improve</a> a little with Python 2.6).</p>
<p>Sometimes you are faced with a library that does SSL, but uses Python&#8217;s socket.ssl that you can&#8217;t easily replace. For this purpose I wrote a little helper module using M2Crypto. Basically you just need to import this <a href="http://svn.osafoundation.org/m2crypto/trunk/demo/ssl/socklib.py">socklib.py</a> before you import the module that is using Python&#8217;s socket.ssl, and call <code>socklib.setSSLContextFactory()</code> with context factory that creates <a href="http://svn.osafoundation.org/m2crypto/trunk/doc/howto.ssl.html#secure">secure SSL contexts</a> and your SSL usage just became secure.</p>
<p>The socklib.py implementation is for client side only. It would be easy to expand it for servers, though. It may also lack some features, but it filled the need I had so that is where I stopped. I wrote it for Python 2.5 and haven&#8217;t thought what would need to be changed for 2.6.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/10/01/how-to-replace-pythons-socketssl-with-m2cryptos-ssl-implementation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Root Certificates for Python Programs using Python</title>
		<link>http://www.heikkitoivonen.net/blog/2008/09/30/root-certificates-for-python-programs-using-python/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/09/30/root-certificates-for-python-programs-using-python/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 03:56:36 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Security]]></category>

		<category><![CDATA[m2crypto]]></category>

		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=307</guid>
		<description><![CDATA[OpenSSL itself does not come with root certificates, which means that if you use OpenSSL for anything that requires those certificates (like SSL for example) you will need to get those certificates from somewhere else. This concerns most Pythonistas needing SSL since most Python programs use OpenSSL for SSL.
Most if not all Linux distributions include [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://openssl.org/">OpenSSL</a> itself does not come with root certificates, which means that if you use OpenSSL for anything that requires those certificates (like SSL for example) you will need to get those certificates from somewhere else. This concerns most Pythonistas needing SSL since most Python programs use OpenSSL for SSL.</p>
<p>Most if not all Linux distributions include various sets of root certificates in OpenSSL-friendly formats. Windows also comes with root certificates, but to get access to them you would need to use the Windows-specific APIs.</p>
<p>The <a href="http://curl.haxx.se/">Curl</a> project produced a crazy little <a href="http://curl.haxx.se/docs/parse-certs.txt">script</a> that can convert the <a href="http://mxr.mozilla.org/seamonkey/source//security/nss/lib/ckfw/builtins/certdata.txt?raw=1">certdata.txt</a> from the <a href="http://www.mozilla.org/projects/security/pki/nss/">NSS</a> project (from Mozilla) into <a href="http://en.wikipedia.org/wiki/X.509#Certificate_filename_extensions">PEM format</a>, suitable for OpenSSL. The Curl project also provided a <a href="http://curl.netmirror.org/docs/caextract.html">converted certdata.txt</a> file for download. Unfortunately the converted file was from a very old version of the certdata.txt file (when I first looked at it). I figured <a href="http://chandlerproject.org/Projects/MeTooCrypto">M2Crypto</a> should have it&#8217;s own utility to do this conversions, so I ended up porting the script into Python. The dirty little <a href="http://svn.osafoundation.org/m2crypto/trunk/demo/x509/certdata2pem.py">certdata2pem.py</a> script uses M2Crypto for certificate handling.</p>
<p>I used my script to get root certificates for <a href="http://chandlerproject.org/">Chandler</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/09/30/root-certificates-for-python-programs-using-python/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python Syntax Influencing New Languages</title>
		<link>http://www.heikkitoivonen.net/blog/2008/09/24/python-syntax-influencing-new-languages/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/09/24/python-syntax-influencing-new-languages/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 05:48:27 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=298</guid>
		<description><![CDATA[To this day C++ is the language I have programmed the longest in (although my Python experience is catching up fast), and at some point I even thought it would be the only programming language I would ever need and use. I actively stayed away from Python, mainly because I had heard about the forced [...]]]></description>
			<content:encoded><![CDATA[<p>To this day C++ is the language I have programmed the longest in (although my Python experience is catching up fast), and at some point I even thought it would be the only programming language I would ever need and use. I actively stayed away from Python, mainly because I had heard about the forced indentation and having had bad experiences with Fortran before. But within two weeks after being forced to use Python I was sold. The Python syntax is definitely one of the attractions. So even though Python itself hasn&#8217;t (yet) taken over the world of programming languages, I am happy to see Python influencing new languages.</p>
<p>A while back <a href="http://jjinux.blogspot.com/">jj</a> pointed out <a href="http://wiki.reia-lang.org/">Reia</a>, which is a language for the <a href="http://en.wikipedia.org/wiki/Erlang_(programming_language)">Erlang</a> virtual machine. The syntax looks a lot like Python&#8217;s, which almost makes me want to play with it. (The concepts of Erlang make it really attractive with the multicore architectures and all, but just reading the Wikipedia article on Erlang made my head hurt because of the syntax.)</p>
<p>Today I was reading about <a href="http://delight.sourceforge.net/">Delight</a>, which is a Python-like syntax for the <a href="http://en.wikipedia.org/wiki/D_programming_language">D</a> programming language. (This is kind of ironic, because D is the nicer C++.) I can&#8217;t say I am sold on all of the ideas of Delight, but I do welcome any attempts to make other programming languages more Pythonic in syntax if nothing else.</p>
<p>Not that long time ago languages marketed themselves by having C-like syntax to make it easier to switch. I am wondering if Python is becoming the new C in that respect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/09/24/python-syntax-influencing-new-languages/feed/</wfw:commentRss>
		</item>
		<item>
		<title>fcgi.py Exposes Python Tracebacks by Default</title>
		<link>http://www.heikkitoivonen.net/blog/2008/09/19/fcgipy-exposes-python-tracebacks-by-default/</link>
		<comments>http://www.heikkitoivonen.net/blog/2008/09/19/fcgipy-exposes-python-tracebacks-by-default/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 07:36:39 +0000</pubDate>
		<dc:creator>Heikki Toivonen</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Security]]></category>

		<category><![CDATA[dreamhost]]></category>

		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=285</guid>
		<description><![CDATA[I was testing a Python web application that was using FastCGI deployment on Dreamhost, when I found myself looking at a souped up Python Traceback in my browser. At first I couldn&#8217;t understand why that was happening. As far as I knew I was running with full production settings and as such I would have [...]]]></description>
			<content:encoded><![CDATA[<p>I was testing a Python web application that was using <a href="http://en.wikipedia.org/wiki/Fastcgi">FastCGI</a> deployment on <a href="http://www.dreamhost.com/">Dreamhost</a>, when I found myself looking at a <a href="http://tools.cherrypy.org/wiki/CGITB">souped up</a> Python Traceback in my browser. At first I couldn&#8217;t understand why that was happening. As far as I knew I was running with full production settings and as such I would have expected a terse internal server error message.</p>
<p>Looking at the HTML source of the error page I discovered reference to <a href="http://www.python.org/doc/lib/module-cgitb.html">cgitb</a>. But as far as my code was concerned I did not set that. I tried specifically disabling that in my script but that made no difference. In a momentary act of desperation I did a find for all cgitb.py files under my account and made the cgitb.enable() function do nothing. Yet I was still seeing the tracebacks.</p>
<p>After a bit of scratching my head and throwing different words at Google it occurred to me to take a look at the <a href="http://svn.saddi.com/py-lib/trunk/fcgi.py">fcgi.py</a> script. Oops. The [WSGI]Server class has an error() method whose docstring states that it &#8220;May and should be overridden&#8221;. No $%^, the default just plasters all the dirty little secrets for the world to see! I&#8217;d like to see something like Debug[WSGI]Server that pretty prints the error, and leave the [WSGI]Server the production class. The naming would make it clear that you should not be using the debug version in production. As it is now, I wonder how many people actually read all the way towards the bottom of the 1331 line file to discover this gem.</p>
<p>I also added a warning to the Dreamhost documentation regarding <a href="http://wiki.dreamhost.com/Python_FastCGI">Python FastCGI</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.heikkitoivonen.net/blog/2008/09/19/fcgipy-exposes-python-tracebacks-by-default/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
