<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Vamsi Pavan's Place</title>
	<link>http://www.vamsipavan.com/blog</link>
	<description>When curiousity outbursts .....</description>
	<pubDate>Sun, 13 May 2012 14:30:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>SSL Authentication in HTTP : Using cURL - Part 3</title>
		<link>http://www.vamsipavan.com/blog/http-ssl-curl-part3/</link>
		<comments>http://www.vamsipavan.com/blog/http-ssl-curl-part3/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 07:39:39 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

		<category><![CDATA[Source Code]]></category>

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/http-ssl-curl-part3/</guid>
		<description><![CDATA[Open source curl is one of best &#38; stable http client tool as well as library. In this article, we&#8217;ll see how can we use libcurl library as well as curl command line utility for two way client authentication.
Using libcurl library for HTTPS client authentication:
Here are the basics steps for the client setup before going [...]]]></description>
			<content:encoded><![CDATA[<p>Open source curl is one of best &amp; stable http client tool as well as library. In this article, we&#8217;ll see how can we use libcurl library as well as curl command line utility for two way client authentication.</p>
<p><b>Using libcurl library for HTTPS client authentication:</b></p>
<p>Here are the basics steps for the client setup before going into actual libcurl code.</p>
<p><b>&nbsp;1. Extract client certificate and client private key files in PEM format from the client keystore.</b></p>
<p>We have client.p12 keystore file in pkcs#12 format and it&#8217;s pass phrase. Following commands can be used further.</p>
<p><b>&nbsp;1.1 Extract client certificate without key.</b></p>
<p>openssl pkcs12 -in client.p12 -nokeys -out clientCert.pem</p>
<p><b>&nbsp;1.2 Extract client private key without cert.</b></p>
<p>openssl pkcs12 -in client.p12 -nocerts -out privateKey.pem</p>
<p>with PEM password. For both above commands ask for keystore pass phrase and only while generating key without cert ask for PEM password (new password will be setup for that key).</p>
<p><b>&nbsp;1.3 Extract both client certificate &amp; key in single file.</p>
<p></b>openssl pkcs12 -in client.p12 -out combinedClient.pem -clcerts<b></p>
<p></b>This prompts for both keystore &amp; PEM pass phrase. Generated file contains both cert &amp; key.</p>
<p><b>&nbsp;2. Option step to verify generated files to crosscheck.</b></p>
<p>openssl x509 -noout -modulus -in clientCert.pem | openssl md5</p>
<p>d7207cf82b771251471672dd54c59927</p>
<p>openssl rsa -noout -modulus -in privateKey.pem | openssl md5</p>
<p>Enter pass phrase for privateKey.pem:</p>
<p>d7207cf82b771251471672dd54c59927</p>
<p>Both these md5 outputs are same and that confirms both are good to go.</p>
<p><b>&nbsp;3. Libcurl client code for client authentication.</b></p>
<p>Using following snippet code for curl easy handle. Actually, for client certificate we don&#8217;t need to set pass phrase, still setting the same PEM pass phrase of client key.</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLCERT,&#8221;clientCert.pem&#8221;);</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLCERTPASSWD,&#8221;changeit&#8221;);</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,&#8221;PEM&#8221;);</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLKEY,&#8221;privateKey.pem&#8221;);</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLKEYPASSWD,&#8221;changeit&#8221;);</p>
<p>curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,&#8221;PEM&#8221;);</p>
<p>Some times, setting client certificate &amp; client key like this by extracting separately will not work with libcurl. It ends with following error sometimes.</p>
<p>*err unable to set private key file: &#8216;C:\privateKey.pem&#8217; type PEM*</p>
<p>Reasons are unknown atleast for me. In that case, solution I found is that use your combinedClient.pem file we generated above in place of client key and client pass phrase in above code snippet (client certificate is optional if you are using combinedClient.pem file). I tried manually appending both client cert &amp; key, but that&#8217;s didn&#8217;t help, so better generate with command only.</p>
<p><b>&nbsp;4. Curl command line tool for client authentication:</b></p>
<p>Following curl command sends C:\myrequest.xml file content as binary HTTP request content with headers SOAPAction &amp; Contenty-Type fields and client cert &amp; client key set to the final url with verbose mode.</p>
<p>$ curl &#8211;data-binary @&#8221;C:\myrequest.xml&#8221; &#8211;header &#8220;SOAPAction: &#8221; &#8211;header<br />&#8220;Content-Type: text/xml&#8221; &#8211;cert c:\clientCert.pem &#8211;cert-type PEM &#8211;key<br />c:\privkey.pem &#8211;key-type PEM &#8211;cacert c:\ca-bundle.crt https://mydomain.myco.com:443/soap -v</p>
<p>It prompts for PEM passwd and then following error.</p>
<p>* About to connect() to mydomain.myco.com port 443 (#0)<br />*&nbsp;&nbsp; Trying 69.181.219.20&#8230; connected<br />* Connected to mydomain.myco.com (69.181.219.20) port 443 (#0)<br />Enter PEM pass phrase:<br />* unable to set private key file: &#8216;privateKey.pem&#8217; type PEM<br />* Closing connection #0<br />*curl: (58) unable to set private key file: &#8216;privateKey.pem&#8217; type PEM*</p>
<p>And then I tried appending both private key along with cert in a single file with format &#8212;&#8211;RSA CERTIFICATE START &#8212;&#8211; &amp; &#8212;-RSA CERT END &#8212;&#8211; then immediately with &#8212;&#8212;CERTIFICATE START &#8212;&#8211; &amp; &#8212;&#8211;CERTIFICATE END &#8212;&#8211; and tried following.</p>
<p>$ curl &#8211;cert testCert.pem &#8211;Verbose -H &#8220;Content-Type: text/xml&#8221;<br />https://mydomain.myco.com:443/soap<br />* About to connect() to mydomain.myco.com port 443 (#0)<br />*&nbsp;&nbsp; Trying 69.181.219.20&#8230; connected<br />* Connected to mydomain.myco.com (69.181.219.20) port 443 (#0)<br />Enter PEM pass phrase:<br />* unable to set private key file: &#8216;testCert.pem&#8217; type PEM<br />* Closing connection #0<br />*curl: (58) unable to set private key file: &#8216;testCert.pem&#8217; type PEM*</p>
<p>Finally, I used the above mentioned command for combined file and then I got the response properly back as below. Following command is used to send both key &amp; cert in a single file with option &#8211;cert and &#8211;cacert option to set cacert bundle file.</p>
<p>$ curl &#8211;cert combinedClient.pem &#8211;data-binary @&#8221;request.xml&#8221; &#8211;Verbose -H &#8220;Content-Type: text/xml&#8221; <br />&#8211;cacert &#8220;ca-bundle.crt&#8221;&nbsp; https://mydomain.myco.com:443/soap</p>
<p>* About to connect() to mydomain.myco.com port 443 (#0)<br />*&nbsp;&nbsp; Trying 69.181.219.20&#8230; connected<br />* Connected to mydomain.myco.com (69.181.219.20) port 443 (#0)<br />Enter PEM pass phrase:<br />* successfully set certificate verify locations:<br />*&nbsp;&nbsp; CAfile: ca-bundle.crt<br />&nbsp; CApath: /usr/ssl/certs<br />* SSLv3, TLS handshake, Client hello (1):<br />* SSLv3, TLS handshake, Server hello (2):<br />* SSLv3, TLS handshake, CERT (11):<br />* SSLv3, TLS handshake, Server key exchange (12):<br />* SSLv3, TLS handshake, Request CERT (13):<br />* SSLv3, TLS handshake, Server finished (14):<br />* SSLv3, TLS handshake, CERT (11):<br />* SSLv3, TLS handshake, Client key exchange (16):<br />* SSLv3, TLS handshake, CERT verify (15):<br />* SSLv3, TLS change cipher, Client hello (1):<br />* SSLv3, TLS handshake, Finished (20):<br />* SSLv3, TLS change cipher, Client hello (1):<br />* SSLv3, TLS handshake, Finished (20):<br />* SSL connection using DHE-RSA-AES256-SHA<br />* Server certificate:<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subject: C=US; ST=New York; L=New York; O=myco; OU=NDIS; CN=mydomain.myco.com<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start date: 2011-06-23 00:00:00 GMT<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; expire date: 2012-07-29 23:59:59 GMT<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; common name: mydomain.myco.com (matched)<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of<br />use at https://www.verisign.com/rpa (c)10; CN=VeriSign Class 3 International Ser<br />ver CA - G3<br />*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSL certificate verify ok.<br />&gt; POST /soap HTTP/1.1<br />&gt; User-Agent: curl/7.19.6 (i686-pc-cygwin) libcurl/7.19.6 OpenSSL/0.9.8n zlib/1.<br />2.3 libidn/1.18 libssh2/1.2<br />&gt; Host: mydomain.myco.com<br />&gt; Accept: */*<br />&gt; Content-Type: text/xml<br />&gt; Content-Length: 586<br />&gt;<br />&lt; HTTP/1.1 200 OK<br />&lt; Date: Tue, 27 Sep 2011 09:16:19 GMT<br />&lt; Server: ACE XML Gateway<br />&lt; Content-Type: text/xml<br />&lt; Content-Length: 498<br />&lt;<br />* Connection #0 to host mydomain.myco.com left intact<br />* Closing connection #0<br />* SSLv3, TLS alert, Client hello (1):<br />&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;&lt;env:Envelope xmlns:env=&#8221;http://schemas.xm<br />lsoap.org/soap/envelope/&#8221; xmlns:dlws=&#8221;http://mydomain.myco.com&#8221;&gt;<br />&lt;env:Body&gt;&lt;dlws:MyResponse&gt;&lt;dlws:statusCode&gt;&lt;dlws:c<br />ode&gt;0&lt;/dlws:code&gt;&lt;dlws:description&gt;Success&lt;/dlws:description&gt;&lt;/dlws:statusCode&gt;&lt;<br />dlws:requestId&gt;f828131e-bab0-4f50-96d0-a2512c7926d4&lt;/dlws:requestId&gt;&lt;dlws:respon<br />seId&gt;1317114979-190385186&lt;/dlws:responseId&gt;&lt;/dlws:MyResponse&gt;&lt;/env:Bo<br />dy&gt;&lt;/env:Envelope&gt;</p>
<p>From all this, the learning I guess is curl behavior is not very sure with respect to client authentication. Some times it works perfectly if we send client cert &amp; key separately, but some times it works only with combined file.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=c79b7d6f-5443-8ee7-8ea8-3429509e4fb8" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/ssl-http-part1/" rel="bookmark">SSL Authentication in HTTP : Basics - Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/ssl-http-part2/" rel="bookmark">SSL Authentication in HTTP : Basics - Part 2</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/evaluation-of-if-statements/" rel="bookmark">Evaluation of if statements</a></li><li><a href="http://www.vamsipavan.com/blog/5-cards-game-solution/" rel="bookmark">5 cards game ... (Solution)</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/http-ssl-curl-part3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SSL Authentication in HTTP : Basics - Part 2</title>
		<link>http://www.vamsipavan.com/blog/ssl-http-part2/</link>
		<comments>http://www.vamsipavan.com/blog/ssl-http-part2/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 13:50:29 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/ssl-http-part2/</guid>
		<description><![CDATA[This article covers to setup both client and server for SSL authentication.
Consider we have java server and keytool utility comes with java sdk.
To create a server certificate follow these steps:
&#160;&#160;&#160; 1. Create the keystore.&#160;&#160;&#160; 2. Export the certificate from the keystore.&#160;&#160;&#160; 3. Sign the certificate.&#160;&#160;&#160; 4. Import the certificate into a trust-store: a repository of [...]]]></description>
			<content:encoded><![CDATA[<p>This article covers to setup both client and server for SSL authentication.</p>
<p>Consider we have java server and keytool utility comes with java sdk.</p>
<p><b>To create a server certificate follow these steps:</b></p>
<p>&nbsp;&nbsp;&nbsp; 1. Create the keystore.<br />&nbsp;&nbsp;&nbsp; 2. Export the certificate from the keystore.<br />&nbsp;&nbsp;&nbsp; 3. Sign the certificate.<br />&nbsp;&nbsp;&nbsp; 4. Import the certificate into a trust-store: a repository of certificates used for verifying the certificates. A trust-store typically contains more than one certificate.</p>
<p>From the directory in which you want to create the keystore, run keytool with the following parameters.</p>
<p><b>&nbsp;&nbsp;&nbsp; 1. Generate the server certificate.</b></p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -genkey -alias &lt;server-alias&gt; -keyalg RSA -keypass changeit -storepass changeit<br />&nbsp;&nbsp;&nbsp; -keystore keystore.jks</p>
<p>&nbsp;&nbsp;&nbsp; When you press Enter, keytool prompts you to enter the server name, organizational unit, organization, locality, state, and country code. Note that you must enter the server name in response to keytool&#8217;s first prompt, in which it asks for first and last names. For testing purposes, this can be localhost. The host specified in the keystore must match the host identified in the host variable specified in /etc/hosts. keystore file can have .jks or .p12 extension. Here we are specifying two pass phrases for each of key &amp; keystore. </p>
<p><b>&nbsp;&nbsp;&nbsp; 2. Export the generated server certificate in keystore.jks into the file server.cer.</b></p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -export -alias &lt;server-alias&gt;&nbsp; -storepass changeit -file server.cer -keystore keystore.jks</p>
<p>&nbsp;&nbsp;&nbsp; If you want to have the certificate signed by a CA, then we need to generate CSR.<br />&nbsp; <br /><b>&nbsp;&nbsp;&nbsp; 2.1 Generate a Certificate Signing Request (CSR)</b></p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -certreq -sigalg RSA -alias &lt;server-alias&gt; -file &lt;csr-filename&gt;</p>
<p>&nbsp;&nbsp;&nbsp; Send the contents of &lt;csr-filename&gt; for signing to CA. Then you get another server.cer file from CA after it is CA signed.</p>
<p><b>&nbsp;&nbsp; 2.2 Generate trust-store for server</b></p>
<p>&nbsp;&nbsp;&nbsp; To create the trust-store file cacerts.jks and add the server certificate to the trust-store, run keytool from the directory where you created the keystore and server certificate. Use the following parameters:</p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -import -v -trustcacerts -alias &lt;server-alias&gt; -file server.cer<br />&nbsp;&nbsp;&nbsp; -keystore cacerts.jks -keypass changeit -storepass changeit</p>
<p>&nbsp;&nbsp;&nbsp; Information on the certificate, such as that shown next, will display. Output of the above command will be.</p>
<p>&nbsp;&nbsp;&nbsp; Owner: CN=localhost, OU=Sun Micro, O=Docs, L=Santa Clara, ST=CA, C=US<br />&nbsp;&nbsp;&nbsp; Issuer: CN=localhost, OU=Sun Micro, O=Docs, L=Santa Clara, ST=CA, C=US<br />&nbsp;&nbsp;&nbsp; Serial number: 3e932169<br />&nbsp;&nbsp;&nbsp; Valid from: Tue Apr 08<br />&nbsp;&nbsp;&nbsp; Certificate fingerprints:<br />&nbsp;&nbsp;&nbsp; MD5: 52:9F:49:68:ED:78:6F:39:87:F3:98:B3:6A:6B:0F:90<br />&nbsp;&nbsp;&nbsp; SHA1: EE:2E:2A:A6:9E:03:9A:3A:1C:17:4A:28:5E:97:20:78:3F:<br />&nbsp;&nbsp;&nbsp; Trust this certificate? [no]:<br />&nbsp;&nbsp;&nbsp; Enter yes, and then press the Enter or Return key. The following information displays:</p>
<p>&nbsp;&nbsp;&nbsp; Certificate was added to keystore<br />&nbsp;&nbsp;&nbsp; [Saving cacerts.jks]</p>
<p>With this we have created a server certificate and configured trust store. Depending on the application you host, you need to make sure of these server.cer file for server certificate along with it&#8217;s pass phrase &amp; cacerts.jks for trusted-store.</p>
<p><b>Creating a Client Certificate for Mutual Authentication:</b></p>
<p>To create a keystore named client-keystore.jks that contains a client certificate named client.cer, follow these steps:</p>
<p>&nbsp;&nbsp;&nbsp; <b>1. Generate the client certificate.</b></p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -genkey -alias &lt;client-alias&gt; -keyalg RSA -keypass changeit<br />&nbsp;&nbsp;&nbsp; -storepass changeit -keystore keystore.jks<br />&nbsp;&nbsp;&nbsp; <br /><b>&nbsp;&nbsp;&nbsp; 2. Export the generated client certificate into the file client.cer.</b></p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -export -alias &lt;client-alias&gt;<br />&nbsp;&nbsp;&nbsp; -storepass changeit -file client.cer -keystore keystore.jks</p>
<p>&nbsp;&nbsp;&nbsp; Add the certificate to the trust-store file cacerts.jks <b>in the server</b>. Run keytool from the directory where you created the keystore and client certificate. Use the following parameters:</p>
<p>&nbsp;&nbsp;&nbsp; &lt;JAVA_HOME&gt;\bin\keytool -import -v -trustcacerts -alias &lt;client-alias&gt; -file client.cer<br />&nbsp;&nbsp;&nbsp; -keystore cacerts.jks -keypass changeit -storepass changeit</p>
<p>&nbsp;&nbsp;&nbsp; The keytool utility returns this message:</p>
<p>&nbsp;&nbsp;&nbsp; Owner: CN=J2EE Client, OU=Java Web Services, O=Sun, L=Santa Clara, ST=CA, C=US<br />&nbsp;&nbsp;&nbsp; Issuer: CN=J2EE Client, OU=Java Web Services, O=Sun, L=Santa Clara, ST=CA, C=US<br />&nbsp;&nbsp;&nbsp; Serial number: 3e39e66a<br />&nbsp;&nbsp;&nbsp; Valid from: Thu Jan 30 18:58:50 PST 2003 until: Wed Apr 30<br />&nbsp;&nbsp;&nbsp; 19:58:50 PDT 2003<br />&nbsp;&nbsp;&nbsp; Certificate fingerprints:<br />&nbsp;&nbsp;&nbsp; MD5: 5A:B0:4C:88:4E:F8:EF:E9:E5:8B:53:BD:D0:AA:8E:5A<br />&nbsp;&nbsp;&nbsp; SHA1:90:00:36:5B:E0:A7:A2:BD:67:DB:EA:37:B9:61:3E:26:B3:89:46:<br />&nbsp;&nbsp;&nbsp; 32<br />&nbsp;&nbsp;&nbsp; Trust this certificate? [no]: yes<br />&nbsp;&nbsp;&nbsp; Certificate was added to keystore</p>
<p>With this we have created client cert and imported in server&#8217;s trusted-store, completed client setup. Coming back to server again.</p>
<p><b>To check the contents of a keystore that contains a certificate with an alias &lt;server-alias&gt;</b>, <br />use this command:</p>
<p>keytool -list -keystore keystore.jks -alias &lt;server-alias&gt; -v</p>
<p><b>To check the contents of the cacerts file</b>, <br />use this command:</p>
<p>keytool -list -keystore cacerts.jks </p>
<p>With this, we have covered server and client setup for SSL certificates for both one way &amp; two way authentication.</p>
<p>Next section, we&#8217;ll see how can we use libcurl as http client for HTTP(S) authentication with both libcurl API &amp; curl command.</p>
<p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=d941cd2e-ef7a-8eaf-a638-c4a1871edbe0" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/ssl-http-part1/" rel="bookmark">SSL Authentication in HTTP : Basics - Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/http-ssl-curl-part3/" rel="bookmark">SSL Authentication in HTTP : Using cURL - Part 3</a></li><li><a href="http://www.vamsipavan.com/blog/limit-robots-action-on-a-specific-page/" rel="bookmark">Limit robots action on a specific page</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/evaluation-of-if-statements/" rel="bookmark">Evaluation of if statements</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/ssl-http-part2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SSL Authentication in HTTP : Basics - Part 1</title>
		<link>http://www.vamsipavan.com/blog/ssl-http-part1/</link>
		<comments>http://www.vamsipavan.com/blog/ssl-http-part1/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 12:52:42 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/ssl-http-part1/</guid>
		<description><![CDATA[Before going into any details of SSL, best thing is to know the following terminology and file formats. HTTP(s) is basically used for secure transactions in HTTP like payments etc.
HTTPS : HTTP protocol on Secure shell which is encrypted to outside for any communication exchange. That way, it is quite secure in HTTP communication.
Keystore : [...]]]></description>
			<content:encoded><![CDATA[<p>Before going into any details of SSL, best thing is to know the following terminology and file formats. HTTP(s) is basically used for secure transactions in HTTP like payments etc.</p>
<p><strong>HTTPS</strong> : HTTP protocol on Secure shell which is encrypted to outside for any communication exchange. That way, it is quite secure in HTTP communication.</p>
<p><strong>Keystore</strong> : keystore is basically a placeholder for a pair of public &amp; private keys. It can hold multiple such pairs.</p>
<p><strong>Key</strong> : It&#8217;s basically a string which is encoded in base64 format (I guess).</p>
<p><strong>PKCS12</strong> : This is the format of keystore file we create by default using openssl or keytool. You can see the respective commands in next part of this series. All most all the browsers expects keystore should be in this format to import the respective certificates. Normally, all keystore files will have extension .p12 in general.</p>
<p><strong>PEM </strong>: This is the format of a file that can be certificate or key or keystore.</p>
<p><strong>DER</strong> : This another format similar to PEM. But PEM is more popular in use.</p>
<p><strong>Certificate</strong> : This basically a digital signature generated using the above pair of public &amp; private keys. This represents some identity of a machine in the secure HTTP world of internet.</p>
<p><strong>Self signed</strong> : After we create a certificate, the next step would be some one has to sign it. If you create a certificate and you are signing the same certificate, then it&#8217;s called self signed. After this, you need to copy your certificate to ca-bundle.cer file in both the machines. This way, you are trusting your own signed certificate.</p>
<p><strong>CA signed</strong> : There are list of CAs (Certificate Authorities) available in the internet who has the right to sign a cert and it is considered to be trusted among all the internet. All most all operating systems and browsers have their certificates listed in that default ca-bundle.cer file as trusted. Though these CA signed certificates are very costly.</p>
<p><strong>cert/cer</strong> : Standard extension for certificate files which can be either PEM or DER format.</p>
<p><strong>keytool</strong> : a utility tool to generate these keystore/keys/certificates supplied along with java sdk.</p>
<p><strong>openssl</strong> : similar to keytool another open source utility tool.</p>
<p><strong>One way authentication in SSL</strong> : In this case, server machine hold a certificate for any HTTPS authentication. When client sends requests to server, first server send this CA signed certificate to identify itself. Client machine check this certificate to it&#8217;s default list of trusted certificates from a file called ca-bundle.cer and depending on that it can further communicate to server. If it find that the certificate is not there in that list, it can have two choices. Either it can proceed further for communication ignoring security aspects or it can stop further communication as it finds it&#8217;s not a trusted server.</p>
<p><strong>Two way authentication is SSL</strong> : In this case, both server and client machines have their own CA singed certificates. When client sends request to server, it gets server certificate. It then verifies the certificate trusted or not, then sends back with it&#8217;s own certificate, then server verifies the same and depending on verification, communication starts on HTTP(S) medium. This method is kind of tricky, you need to configure you HTTP client (by which you will be sending request to server, normally a web browser) with client certificate as well as private key too.</p>
<p>We&#8217;ll see the commands to create these keystores, keys, certificates and along communicate with servers using curl (open source http client) in our next part of this series.</p>
<p class="zemanta-pixie"><img src="http://img.zemanta.com/pixy.gif?x-id=ddc2e4c0-b0a9-8a2c-ad53-c438d736c6d1" class="zemanta-pixie-img" /></p>
<p class="zemanta-pixie"><a href="http://www.vamsipavan.com/blog/ssl-http-part2/" target="_blank">For Part 2 click here</a>.</p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/ssl-http-part2/" rel="bookmark">SSL Authentication in HTTP : Basics - Part 2</a></li><li><a href="http://www.vamsipavan.com/blog/http-ssl-curl-part3/" rel="bookmark">SSL Authentication in HTTP : Using cURL - Part 3</a></li><li><a href="http://www.vamsipavan.com/blog/limit-robots-action-on-a-specific-page/" rel="bookmark">Limit robots action on a specific page</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/evaluation-of-if-statements/" rel="bookmark">Evaluation of if statements</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/ssl-http-part1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bangalore - story behind the name</title>
		<link>http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/</link>
		<comments>http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 04:27:51 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/</guid>
		<description><![CDATA[Legend goes that King Veeraballa of Vijayanagara once lost his way in forest. Hungry and tired, he came upon a lone hut in the thick forest where he met an old woman.When he asked for food, she gave him baked beans (&#8217;Benda Kalu&#8217; in Karnataka).The King found this humble meal taste better than the richest [...]]]></description>
			<content:encoded><![CDATA[<p>Legend goes that King Veeraballa of Vijayanagara once lost his way in <br />forest. Hungry and tired, he came upon a lone hut in the thick forest <br />where he met an old woman.When he asked for food, she gave him baked <br />beans (&#8217;Benda Kalu&#8217; in Karnataka).The King found this humble meal taste <br />better than the richest fare.To commemorate this incident, he called the<br /> place &#8220;Benda Kalu Ooru&#8221; (place of baked beans). Bangalore today is <br />getting popular though for a different variety of Beans-JavaBeans <img src='http://www.vamsipavan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=1152e295-0a40-84a3-91b3-9c03225b51f4" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/donkey-story-3/" rel="bookmark">Donkey Story 3</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-1/" rel="bookmark">Donkey Story 1</a></li><li><a href="http://www.vamsipavan.com/blog/indian-real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 2 (Indian context)</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/feed/</wfw:commentRss>
		</item>
		<item>
		<title>xerces-c: C++ SAX2 Parser</title>
		<link>http://www.vamsipavan.com/blog/xerces-c-sax2-parser/</link>
		<comments>http://www.vamsipavan.com/blog/xerces-c-sax2-parser/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 04:25:32 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Source Code]]></category>

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

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

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

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

		<category><![CDATA[xerces-c]]></category>

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/xerces-c-sax2-parser/</guid>
		<description><![CDATA[Basics of validating xmls with a given schema in C++.
1. Create parser instance.

SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();


2. Set required features to parser instance as follow.
// Enable the parser&#8217;s schema support parser-&#62;setFeature(XMLUni::fgXercesSchema, true);
// Schema validation requires namespace processing to be turned on.&#60;br /&#62;parser-&#62;setFeature(XMLUni::fgSAX2CoreValidation,true);&#60;br /&#62;parser-&#62;setFeature(XMLUni::fgSAX2CoreNameSpaces,true);

3. Set schema location using setPropery api call with/without namespace. If we want use [...]]]></description>
			<content:encoded><![CDATA[<p>Basics of validating xmls with a given schema in C++.</p>
<p>1. Create parser instance.<br />
<blockquote>
<pre class="default prettyprint">SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
</pre>
</blockquote>
<p>2. Set required features to parser instance as follow.<br />
<blockquote>// Enable the parser&#8217;s schema support <br />parser-&gt;setFeature(XMLUni::fgXercesSchema, true);</p></blockquote>
<blockquote><pre class="default prettyprint">// Schema validation requires namespace processing to be turned on.&lt;br /&gt;parser-&gt;setFeature(XMLUni::fgSAX2CoreValidation,true);&lt;br /&gt;parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpaces,true);</pre>
</blockquote>
<p>3. Set schema location using setPropery api call with/without namespace. If we want use &#8216;ExternalSchemaLocation&#8217; property we need to append Namespace with a space char and then schema file path.<br />
<blockquote>// Define the location of the schema.<br />XMLCh* schemaLocation = XMLString::transcode(&#8221;/directory/path/myschema.xsd&#8221;);<br />parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,schemaLocation);</p></blockquote>
<p>Current parser version requires the path in below format.<br />
<blockquote>XMLCh* propertyValue = XMLString::transcode(&#8221;myschema.xsd&#8221;);<br />ArrayJanitor<xmlch> janValue(propertyValue);<br />parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,propertyValue);<br /></xmlch></p></blockquote>
<p>Another important thing to remember is - <b>always file path should be in &#8220;file:///
<path to="" file="" with="" replaced="" \s="">&#8220;.</path></b> If you don&#8217;t follow this format, parser won&#8217;t complain anything but validation/parsing don&#8217;t go well. Fortunately, if you are using in java, File API class provides you getURL() call to get the path in file protocol.</p>
<p>4. Now, set the content as well as error handler to parser instance. Remember always use custom handler by inheriting from DefaultHanlder while setting these. For error handler, inherited methods error(), warning(), fatal() needs to be overridden, otherwise parsing/validation errors go unnoticed without catching the exceptions. <br />
<blockquote>
<pre class="default prettyprint">parser-&gt;setContentHandler((ContentHandler*) myContentHandler);&lt;br /&gt;parser-&gt;setErrorHandler((ErrorHandler*) myContentHandler);</pre>
</blockquote>
<p>5. Finally, parse api call.<br />
<blockquote>
<pre class="default prettyprint">// Do the parse&lt;br /&gt;parser-&gt;parse(*xmlInputSource);</pre>
</blockquote>
<p>6. Now complete code would be.
<div align="left">
<blockquote>&nbsp;&nbsp;&nbsp; SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgSAX2CoreValidation, true);<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpaces, true);<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; //* Enable strict validation<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgXercesValidationErrorAsFatal, true);</p>
<p>&nbsp;&nbsp;&nbsp; //* Enable the parser&#8217;s schema support <br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgXercesSchema, true);<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgXercesSchemaFullChecking, true);<br />&nbsp;&nbsp;&nbsp; parser-&gt;setFeature(XMLUni::fgXercesDynamic, false);</p>
<p>&nbsp;&nbsp;&nbsp; XMLCh* propertyValue = XMLString::transcode(m_sDefSchema.getMBCSCopy());<br />&nbsp;&nbsp;&nbsp; ArrayJanitor&lt;XMLCh&gt; janValue(propertyValue);</p>
<p>&nbsp;&nbsp;&nbsp; //* Define the location of the XML schema.<br />&nbsp;&nbsp;&nbsp; if(isNS)&nbsp; //with/without namespace<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Property name - http://apache.org/xml/properties/schema/external-schemaLocation<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,propertyValue);<br />&nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Property name - http://apache.org/xml/properties/schema/external-noNameSpaceSchemaLocation<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,propertyValue);</p></blockquote>
</div>
<p>Now, we&#8217;ll see the common errors we face during validation development. For most of the errors, we should make sure that Schema is having or not having target namespace. According to that parser/validator behave further.</p>
<p>1. <i>Character &#8216;&lt;&#8217; is grammatically unexpected</i><br />Cause: missing required tag.</p>
<p>2. <i>[cvc-elt.1: Cannot find the declaration of element</i><br />Cause: no namespace is found in the xml or Parser&#8217;s schemalocation property doesn&#8217;t have namespace attached or Schema files were missing at the specified path for parser&#8217;s schemalocation property.</p>
<p>This list will be updated in future too.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=b4470cf7-376e-8c94-8021-c7e9a5920469" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/xerces-c-c-sax2-parser/" rel="bookmark">xerces-c: C++ SAX2 Parser</a></li><li><a href="http://www.vamsipavan.com/blog/difference-between-require-and-use/" rel="bookmark">Difference between require and use ?</a></li><li><a href="http://www.vamsipavan.com/blog/file-upload-code-in-jsp-other-methods/" rel="bookmark">File upload code in Jsp : other methods &#8230;.</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/xerces-c-sax2-parser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Donkey Story 3</title>
		<link>http://www.vamsipavan.com/blog/donkey-story-3/</link>
		<comments>http://www.vamsipavan.com/blog/donkey-story-3/#comments</comments>
		<pubDate>Sun, 08 May 2011 09:39:40 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/donkey-story-3/</guid>
		<description><![CDATA[There was once a washer man who had a donkey and a dog.  
One night when the whole world was sleeping, a thief broke into the  house, the washer man was fast asleep but the donkey and the dog were  awake.  
The dog decided not to bark since the master did [...]]]></description>
			<content:encoded><![CDATA[<p><span class="comment-body" data-li-comment-text="">There was once a washer man who had a donkey and a dog.  </p>
<p>One night when the whole world was sleeping, a thief broke into the  house, the washer man was fast asleep but the donkey and the dog were  awake.  </p>
<p>The dog decided not to bark since the master did not take good care of him and wanted to teach him a lesson.  </p>
<p>The donkey got worried and said to the dog that if he doesn’t bark, the  donkey will have to do something himself. The dog did not change his  mind and the donkey started braying loudly.  </p>
<p>Hearing the donkey bray, the thief ran away, the master woke up and  started beating the donkey for braying in the middle of the night for no reason.  </p>
<p>Moral of the story ”Donkey shall Donkey&#8217;s work and Dog Shall do Dog&#8217;s work&#8217; <br />&#8212;&#8211; <br />PS: The extension of this story is : <br />&#8212;&#8211; <br />The washer man was a well educated man from a premier management institute.  </p>
<p>He had the fundas of looking at the bigger picture and thinking out of  the box. He was convinced that there must be some reason for the donkey  to bray in the night.  </p>
<p>He walked outside a little and did some fact finding, applied a bottom  up approach, figured out from the ground realities that there was a  thief who broke in and the donkey only wanted to alert him about it.  </p>
<p>Looking at the donkey’s extra initiative and going beyond the call of  the duty, he rewarded him with lot of hay and other perks and became his favorite pet.  </p>
<p>The dog’s life didn’t change much, except that now the donkey was more  motivated in doing the dogs duties as well. In the annual appraisal the  dog managed a ” meets requirement” Soon the dog realized that the donkey is taking care of his duties and he can enjoy his life sleeping and  lazing around.  </p>
<p>The donkey was rated as “star performer”. The donkey had to live up to  his already high performance standards. Soon he was over burdened with  work and always under pressure and now is looking for a job rotation…  </p>
<p>If you have worked in a corporate environment, I am sure you have guessed the characters of the new story. </span></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=df3e2ab5-7033-8342-80ae-bb43f5f002dd" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-1/" rel="bookmark">Donkey Story 1</a></li><li><a href="http://www.vamsipavan.com/blog/real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/" rel="bookmark">Bangalore - story behind the name</a></li><li><a href="http://www.vamsipavan.com/blog/indian-real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 2 (Indian context)</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/donkey-story-3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Donkey story 2</title>
		<link>http://www.vamsipavan.com/blog/donkey-story-2/</link>
		<comments>http://www.vamsipavan.com/blog/donkey-story-2/#comments</comments>
		<pubDate>Sun, 08 May 2011 09:37:32 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

		<category><![CDATA[donkey story]]></category>

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/donkey-story-2/</guid>
		<description><![CDATA[There was a salt  merchant who used a donkey to transport salt bags. On their way they  had to cross a stream of water slightly less than knee deep.  
Accidentally the donkey fell one day in the waters and to its surprise  it noticed  reduction in its load and hence [...]]]></description>
			<content:encoded><![CDATA[<p><span class="comment-body" data-li-comment-text="">There was a salt  merchant who used a donkey to transport salt bags. On their way they  had to cross a stream of water slightly less than knee deep.  </p>
<p>Accidentally the donkey fell one day in the waters and to its surprise  it noticed  reduction in its load and hence forth it made it a practice  to do it daily. </p>
<p>Merchant was helpless as he was losing some salt in the  transport resulting in loss. He decided to teach the donkey a lesson and one day loaded it bags of cotton instead of salt. </p>
<p>The donkey was  thrilled as the initial load itself was very light, nevertheless greed  was part of  now intelligent donkey and it dipped in water as usual   &#8230;&#8230;&#8230;&#8230;&#8230;.. and somehow it made it home. </p>
<p><b>Moral</b> of the story ,  assume all are smart in this world !                  </span></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=548de1b0-4d00-8df4-a4a1-6513300ea97e" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/donkey-story-3/" rel="bookmark">Donkey Story 3</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-1/" rel="bookmark">Donkey Story 1</a></li><li><a href="http://www.vamsipavan.com/blog/real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/" rel="bookmark">Bangalore - story behind the name</a></li><li><a href="http://www.vamsipavan.com/blog/indian-real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 2 (Indian context)</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/donkey-story-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Donkey Story 1</title>
		<link>http://www.vamsipavan.com/blog/donkey-story-1/</link>
		<comments>http://www.vamsipavan.com/blog/donkey-story-1/#comments</comments>
		<pubDate>Sun, 08 May 2011 09:33:56 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Articles]]></category>

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/donkey-story-1/</guid>
		<description><![CDATA[One day a farmer&#8217;s donkey fell down into a well. The animal cried  piteously for hours as the farmer tried to figure out what to do.  Finally, he decided the animal was old, and the well needed to be  covered up anyway; it just wasn&#8217;t worth it to retrieve the donkey. 
He [...]]]></description>
			<content:encoded><![CDATA[<p>One day a farmer&#8217;s donkey fell down into a well. The animal cried  piteously for hours as the farmer tried to figure out what to do.  Finally, he decided the animal was old, and the well needed to be  covered up anyway; it just wasn&#8217;t worth it to retrieve the donkey. </p>
<p>He invited all his neighbors to come over and help him. They all  grabbed a shovel and began to shovel dirt into the well. At first, the  donkey realized what was happening and cried horribly. Then, to  everyone&#8217;s amazement he quieted down. <br />A few shovel loads later, the farmer finally looked down the well. He  was astonished at what he saw. With each shovel of dirt that hit his  back, the donkey was doing something amazing. He would shake it off and  take a step up. </p>
<p>As the farmer&#8217;s neighbors continued to shovel dirt on top of the  animal, he would shake it off and take a step up. Pretty soon, <br />everyone was amazed as the donkey stepped up over the edge of the well and happily trotted off! </p>
<p>MORAL : <br />Life is going to shovel dirt on you, all kinds of dirt. The trick to  getting out of the well is to shake it off and take a step up. Each of  our troubles is a steppingstone. We can get out of the deepest wells  just by not stopping, never giving up! Shake it off and take a step up. </p>
<p>Remember the five simple rules to be happy: </p>
<p>1. Free your heart from hatred - Forgive. </p>
<p>2. Free your mind from worries - Most never happen. </p>
<p>3. Live simply and appreciate what you have. </p>
<p>4. Give more. </p>
<p>5. Expect less </p>
<p>and the last bust not the least&#8230; </p>
<p>6.For success always network..network the in thing in today&#8217;s business </p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=28bd74fe-5a81-8ef0-bd00-5df3d50da278" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/donkey-story-3/" rel="bookmark">Donkey Story 3</a></li><li><a href="http://www.vamsipavan.com/blog/donkey-story-2/" rel="bookmark">Donkey story 2</a></li><li><a href="http://www.vamsipavan.com/blog/real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 1</a></li><li><a href="http://www.vamsipavan.com/blog/bangalore-story-behind-the-name/" rel="bookmark">Bangalore - story behind the name</a></li><li><a href="http://www.vamsipavan.com/blog/indian-real-estate-bubble-2008/" rel="bookmark">Real Estate Bubble 2008 : Part 2 (Indian context)</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/donkey-story-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Eclipse: resource is outof sync with the file system - permanent solution</title>
		<link>http://www.vamsipavan.com/blog/eclipse-resource-is-outof-sync-with-the-file-system-permanent-solution/</link>
		<comments>http://www.vamsipavan.com/blog/eclipse-resource-is-outof-sync-with-the-file-system-permanent-solution/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 13:54:34 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

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

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

		<category><![CDATA[out of sync file system.]]></category>

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/eclipse-resource-is-outof-sync-with-the-file-system-permanent-solution/</guid>
		<description><![CDATA[
 Mysteriously got the following exception when trying to build an Eclipse project:  
 &#8220;resource is out of sync with the file system&#8221;  
 Although I can&#8217;t be sure, I think I may have deleted a file  outside of Eclipse. To fix the problem, right click the project or  edited resource [...]]]></description>
			<content:encoded><![CDATA[<div class="postText">
<p> Mysteriously got the following exception when trying to build an Eclipse project:  </p>
<p> &#8220;resource is out of sync with the file system&#8221;  </p>
<p> Although I can&#8217;t be sure, I <em>think</em> I may have deleted a file  outside of Eclipse. To fix the problem, right click the project or  edited resource and select &#8220;Refresh&#8221;. Alternatively, you can enable  auto-refresh by going to Window-&gt;Preferences menu, then in the  Preferences dialog box, select General-&gt;Workspace. Check the &#8220;Refresh automatically&#8221; box.  </p>
<p> This is for Eclipse 3.3. I don&#8217;t know about other versions. </p>
<p>When we have so many project out of sync, this would really help as it did to me.</p>
</p></div>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" alt="" src="http://img.zemanta.com/pixy.gif?x-id=87001236-b5c3-879a-bffb-6e5661dd3ddb" /></div>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/difference-between-require-and-use/" rel="bookmark">Difference between require and use ?</a></li><li><a href="http://www.vamsipavan.com/blog/the-role-of-partitions-in-a-linux-file-system/" rel="bookmark">The role of partitions in a Linux file system</a></li><li><a href="http://www.vamsipavan.com/blog/default-desktop-problem/" rel="bookmark">Default desktop problem</a></li><li><a href="http://www.vamsipavan.com/blog/avoid-multiple-inclusion-of-header-file/" rel="bookmark">Avoid multiple inclusion of header file</a></li><li><a href="http://www.vamsipavan.com/blog/write-permissions-to-vfat-filesystems-for-normal-users/" rel="bookmark">Write permissions to vfat filesystems for normal users</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/eclipse-resource-is-outof-sync-with-the-file-system-permanent-solution/feed/</wfw:commentRss>
		</item>
		<item>
		<title>xerces-c: C++ SAX2 Parser</title>
		<link>http://www.vamsipavan.com/blog/xerces-c-c-sax2-parser/</link>
		<comments>http://www.vamsipavan.com/blog/xerces-c-c-sax2-parser/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 16:17:16 +0000</pubDate>
		<dc:creator>Pa1</dc:creator>
		
		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Source Code]]></category>

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

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

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

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

		<category><![CDATA[xerces-c]]></category>

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

		<guid isPermaLink="false">http://www.vamsipavan.com/blog/xerces-c-c-sax2-parser/</guid>
		<description><![CDATA[Basics of validating xmls with a given schema.
1. Create parser instance.

SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();

2. Set required features to parser instance as follow.
// Enable the parser&#8217;s schema support
parser-&#62;setFeature(XMLUni::fgXercesSchema, true);

// Schema validation requires namespace processing to be turned on.
parser-&#62;setFeature(XMLUni::fgSAX2CoreValidation,true);
parser-&#62;setFeature(XMLUni::fgSAX2CoreNameSpaces,true);

3. Set schema location using setPropery api call with/without namespace. If we want use &#8216;ExternalSchemaLocation&#8217; property we need to [...]]]></description>
			<content:encoded><![CDATA[<p>Basics of validating xmls with a given schema.</p>
<p>1. Create parser instance.</p>
<blockquote>
<pre class="default prettyprint">SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();</pre>
</blockquote>
<p>2. Set required features to parser instance as follow.</p>
<blockquote><p>// Enable the parser&#8217;s schema support<br />
parser-&gt;setFeature(XMLUni::fgXercesSchema, true);</p></blockquote>
<blockquote>
<pre class="default prettyprint">// Schema validation requires namespace processing to be turned on.</pre>
<pre class="default prettyprint">parser-&gt;setFeature(XMLUni::fgSAX2CoreValidation,true);</pre>
<pre class="default prettyprint">parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpaces,true);</pre>
</blockquote>
<p>3. Set schema location using setPropery api call with/without namespace. If we want use &#8216;ExternalSchemaLocation&#8217; property we need to append Namespace with a space char and then schema file path.</p>
<blockquote><p>// Define the location of the schema.<br />
XMLCh* schemaLocation = XMLString::transcode(&#8221;/directory/path/myschema.xsd&#8221;);<br />
parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,schemaLocation);</p></blockquote>
<p>Current parser version requires the path in below format.</p>
<blockquote><p>XMLCh* propertyValue = XMLString::transcode(&#8221;myschema.xsd&#8221;);<br />
ArrayJanitor<xmlch> janValue(propertyValue);<br />
parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,propertyValue);<br />
</xmlch></p></blockquote>
<p>Another important thing to remember is - <strong>always file path should be in &#8220;file:///</p>
<path>&#8220;.</path></strong> If you don&#8217;t follow this format, parser won&#8217;t complain anything but validation/parsing don&#8217;t go well. Fortunately, if you are using in java, File API class provides you getURL() call to get the path in file protocol.</p>
<p>4. Now, set the content as well as error handler to parser instance. Remember always use custom handler by inheriting from DefaultHanlder while setting these. For error handler, inherited methods error(), warning(), fatal() needs to be overridden, otherwise parsing/validation errors go unnoticed without catching the exceptions.</p>
<blockquote>
<pre class="default prettyprint">parser-&gt;setContentHandler((ContentHandler*) myContentHandler);</pre>
<pre class="default prettyprint">parser-&gt;setErrorHandler((ErrorHandler*) myContentHandler);</pre>
</blockquote>
<p>5. Finally, parse api call.</p>
<blockquote>
<pre class="default prettyprint">// Do the parse.</pre>
<pre class="default prettyprint">parser-&gt;parse(*xmlInputSource);</pre>
</blockquote>
<p>6. Now complete code would be.</p>
<p align="left">
<blockquote><p>    SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();<br />
parser-&gt;setFeature(XMLUni::fgSAX2CoreValidation, true);<br />
parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpaces, true);</p>
<p>//* Enable strict validation<br />
parser-&gt;setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);<br />
parser-&gt;setFeature(XMLUni::fgXercesValidationErrorAsFatal, true);    //* Enable the parser&#8217;s schema support<br />
parser-&gt;setFeature(XMLUni::fgXercesSchema, true);<br />
parser-&gt;setFeature(XMLUni::fgXercesSchemaFullChecking, true);<br />
parser-&gt;setFeature(XMLUni::fgXercesDynamic, false);</p>
<p>XMLCh* propertyValue = XMLString::transcode(m_sDefSchema.getMBCSCopy());<br />
ArrayJanitor&lt;XMLCh&gt; janValue(propertyValue);</p>
<p>//* Define the location of the XML schema.<br />
if(isNS)  //with/without namespace<br />
//Property name - http://apache.org/xml/properties/schema/external-schemaLocation<br />
parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation,propertyValue);<br />
else<br />
//Property name - http://apache.org/xml/properties/schema/external-noNameSpaceSchemaLocation<br />
parser-&gt;setProperty(XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation,propertyValue);</p></blockquote>
<p>Now, we&#8217;ll see the common errors we face during validation development. For most of the errors, we should make sure that Schema is having or not having target namespace. According to that parser/validator behave further.</p>
<p>1. <em>Character &#8216;&lt;&#8217; is grammatically unexpected</em><br />
Cause: missing required tag.</p>
<p>2. <em>[cvc-elt.1: Cannot find the declaration of element</em><br />
Cause: no namespace is found in the xml or Parser&#8217;s schemalocation property doesn&#8217;t have namespace attached or Schema files were missing at the specified path for parser&#8217;s schemalocation property.</p>
<p>This list will be updated in future too.</p>
<p class="zemanta-pixie"><img src="http://img.zemanta.com/pixy.gif?x-id=26098dab-d49c-8e0a-9869-147099eec01f" class="zemanta-pixie-img" /></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.vamsipavan.com/blog/xerces-c-sax2-parser/" rel="bookmark">xerces-c: C++ SAX2 Parser</a></li><li><a href="http://www.vamsipavan.com/blog/difference-between-require-and-use/" rel="bookmark">Difference between require and use ?</a></li><li><a href="http://www.vamsipavan.com/blog/file-upload-code-in-jsp-other-methods/" rel="bookmark">File upload code in Jsp : other methods &#8230;.</a></li></ul></div><br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.vamsipavan.com/blog/xerces-c-c-sax2-parser/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

