<?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>CertPal &#187; debug</title>
	<atom:link href="http://www.certpal.com/blogs/tag/debug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.certpal.com/blogs</link>
	<description>Technology and certifications</description>
	<lastBuildDate>Mon, 18 Jul 2011 06:48:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Debugging HTTPS traffic</title>
		<link>http://www.certpal.com/blogs/2009/12/debugging-https-traffic/</link>
		<comments>http://www.certpal.com/blogs/2009/12/debugging-https-traffic/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 05:49:11 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=495</guid>
		<description><![CDATA[If you have to deal with HTTPS traffic and sniff it, it is possible. Learn a trick that debugging proxies use to analyze secure data and how they work around it. There are some drawbacks however, but developers can work around them.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F12%2Fdebugging-https-traffic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F12%2Fdebugging-https-traffic%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-503" title="security_lock" src="http://www.certpal.com/blogs/wp-content/uploads/security_lock.png" alt="security_lock" width="79" height="104" />There are times when you work with SSL traffic. Your website might be protected with a certificate so that traffic between you and the client is secure. At times like this, being a developer is troublesome. Browser cache settings need to be analyzed by looking at the HTTP headers. Encoding / Content type may need to be analyzed to ensure that a particular page is displayed correctly. These things cannot be looked into if the traffic is secure. There are situations under which the environment is secure but you must still sniff the data. So how do you manage this ?</p>
<p>Tools like <a href="http://www.charlesproxy.com/" target="_blank">Charles </a>(A debugging proxy) help you do this. Charles allows you to proxy to a secure connection over a protocol like HTTPS and still read the traffic. So how does it do this ? Lets have a look.</p>
<p>Your environment probably has a self signed certificate like the one issued below, using keytool.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">keytool <span style="color: #339933;">-</span>genkey <span style="color: #339933;">-</span>keyalg RSA <span style="color: #339933;">-</span>keysize <span style="color: #cc66cc;">1024</span> <span style="color: #339933;">-</span>alias example.<span style="color: #006633;">com</span> <span style="color: #339933;">-</span>keystore mystore.<span style="color: #006633;">ks</span> <span style="color: #339933;">-</span>validity <span style="color: #cc66cc;">9999</span>
&nbsp;
keytool <span style="color: #339933;">-</span>list <span style="color: #339933;">-</span>keystore .<span style="color: #339933;">/</span>mystore.<span style="color: #006633;">ks</span> <span style="color: #339933;">-</span>v
&nbsp;
Enter keystore password<span style="color: #339933;">:</span>  changeit
&nbsp;
Keystore type<span style="color: #339933;">:</span> jks
Keystore provider<span style="color: #339933;">:</span> SUN
&nbsp;
Your keystore contains <span style="color: #cc66cc;">1</span> entry
&nbsp;
Alias name<span style="color: #339933;">:</span> example.<span style="color: #006633;">com</span>
Creation date<span style="color: #339933;">:</span> Dec <span style="color: #cc66cc;">21</span>, <span style="color: #cc66cc;">2009</span>
Entry type<span style="color: #339933;">:</span> keyEntry
<span style="color: #003399;">Certificate</span> chain length<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span>
<span style="color: #003399;">Certificate</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">:</span>
<span style="color: #003399;">Owner</span><span style="color: #339933;">:</span> CN<span style="color: #339933;">=</span>www.<span style="color: #006633;">org</span>.<span style="color: #006633;">com</span>, OU<span style="color: #339933;">=</span>Org, O<span style="color: #339933;">=</span>SomeCompany, L<span style="color: #339933;">=</span>Somewhere, ST<span style="color: #339933;">=</span>Someplace, C<span style="color: #339933;">=</span>US
Issuer<span style="color: #339933;">:</span> CN<span style="color: #339933;">=</span>www.<span style="color: #006633;">org</span>.<span style="color: #006633;">com</span>, OU<span style="color: #339933;">=</span>Org, O<span style="color: #339933;">=</span>SomeCompany, L<span style="color: #339933;">=</span>Somewhere, ST<span style="color: #339933;">=</span>Someplace, C<span style="color: #339933;">=</span>US
Serial number<span style="color: #339933;">:</span> 4b2ef9e0
Valid from<span style="color: #339933;">:</span> Mon Dec <span style="color: #cc66cc;">21</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span>00<span style="color: #339933;">:</span><span style="color: #cc66cc;">24</span> GMT<span style="color: #339933;">+</span>05<span style="color: #339933;">:</span><span style="color: #cc66cc;">30</span> <span style="color: #cc66cc;">2009</span> until<span style="color: #339933;">:</span> Thu May 07 <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span>00<span style="color: #339933;">:</span><span style="color: #cc66cc;">24</span> GMT<span style="color: #339933;">+</span>05<span style="color: #339933;">:</span><span style="color: #cc66cc;">30</span> <span style="color: #cc66cc;">2037</span>
<span style="color: #003399;">Certificate</span> fingerprints<span style="color: #339933;">:</span>
MD5<span style="color: #339933;">:</span>  XX<span style="color: #339933;">:</span>XX<span style="color: #339933;">:</span>XX...
<span style="color: #006633;">SHA1</span><span style="color: #339933;">:</span> XX<span style="color: #339933;">:</span>XX<span style="color: #339933;">:</span>XX...
&nbsp;
<span style="color: #339933;">*******************************************</span>
<span style="color: #339933;">*******************************************</span></pre></div></div>

<p>When a certificate like this one is presented to a web browser, it will look like so. Let&#8217;s extract the certificate and open it up.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">keytool <span style="color: #339933;">-</span>export <span style="color: #339933;">-</span>keystore .<span style="color: #339933;">/</span>mystore.<span style="color: #006633;">ks</span> <span style="color: #339933;">-</span>file .<span style="color: #339933;">/</span>testtex.<span style="color: #006633;">crt</span> <span style="color: #339933;">-</span>alias example.<span style="color: #006633;">com</span></pre></div></div>

<p><strong>Untrusted self signed certificate:</strong></p>
<p><img class="aligncenter size-full wp-image-496" title="cert_not_trusted" src="http://www.certpal.com/blogs/wp-content/uploads/cert_not_trusted.png" alt="cert_not_trusted" width="345" height="355" /></p>
<p>Our certificate is obviously not trusted since it is self signed. A certificate signed by a CA will not exhibit a security warning. Like the one presented by google for the gmail login page, which is shown below</p>
<p><strong>Trusted certificate from google.com:</strong></p>
<p><img class="aligncenter size-full wp-image-498" title="google_cert_hierarchy" src="http://www.certpal.com/blogs/wp-content/uploads/google_cert_hierarchy.png" alt="google_cert_hierarchy" width="511" height="361" /></p>
<p>When you start a proxy that has HTTPS support, say charles for instance, it does the magic by inserting its own certificate into the certificate hierarchy. The Charles CA Certificate, now becomes the root certificate in this hierarchy, allowing it to decrypt the information that is sent between the client and server.</p>
<p><strong>Modified certificate hierarchy:</strong></p>
<p><img class="aligncenter size-full wp-image-499" title="charles_google_cert" src="http://www.certpal.com/blogs/wp-content/uploads/charles_google_cert.png" alt="charles_google_cert" width="520" height="611" /></p>
<p>Charles signs the certificate that google presents, so it will now be able to decrypt the information that is sent by the server. However the side effect is that your browser will no longer trust this certificate since the root CA is not in your trusted store.</p>
<p><strong>Untrusted connection due to modified hierarchy:</strong></p>
<p><img class="aligncenter size-full wp-image-500" title="charles_connection_not_trusted" src="http://www.certpal.com/blogs/wp-content/uploads/charles_connection_not_trusted.png" alt="charles_connection_not_trusted" width="574" height="308" /></p>
<p>You can get over the problem by importing the certificate or installing it into the MS trust store. This is one technique that proxies use to debug traffic. Know of another method / proxy software ?  Leave a comment. Happy debugging <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2009/12/debugging-https-traffic/';</script><br />
<script type="text/javascript">var dzone_title = 'Debugging HTTPS traffic';</script><br />
<script type="text/javascript">var dzone_blurb = '[description]';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F12%2Fdebugging-https-traffic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F12%2Fdebugging-https-traffic%2F&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2009/12/debugging-https-traffic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

