<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Adarsh's blog : HttpWebRequest</title><link>http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx</link><description>Tags: HttpWebRequest</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Client side certificate with strong key protection and WebServices</title><link>http://blogs.msdn.com/adarshk/archive/2005/02/17/375479.aspx</link><pubDate>Thu, 17 Feb 2005 21:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:375479</guid><dc:creator>adarshk</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/375479.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=375479</wfw:commentRss><description>&lt;P&gt;When you are writing application to run as service or middle tier, which is using client certificates. You should not enable strong key protection during certificate installation. &lt;/P&gt;
&lt;P&gt;Strong key protection is the way you are informing the system that whenever someone want to use this protected resource (client certifcate) then prompt me for the permission. In middle tier environment you really do not want this prompt, you really want to run your application unattended. In fact with .Net frameworks 1.1, SP1 you won't be able to use the certificate with strong key protection.&lt;/P&gt;
&lt;P&gt;Check the posting from Kevin W. Hammond about his experience on this issue&lt;/P&gt;
&lt;P&gt;&lt;a href="http://blogs.msdn.com/kevinha/archive/2005/02/15/373254.aspx"&gt;http://blogs.msdn.com/kevinha/archive/2005/02/15/373254.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;EM&gt;&lt;FONT size=2&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=375479" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx">SSL</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>Understanding HttpWebRequest Connection Management and ServicepointManager</title><link>http://blogs.msdn.com/adarshk/archive/2005/01/02/345413.aspx</link><pubDate>Sun, 02 Jan 2005 10:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:345413</guid><dc:creator>adarshk</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/345413.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=345413</wfw:commentRss><description>&lt;p&gt;If you are looking for some information on understanding the basics of HttpWebRequest connection management and servicepointmanager, I just posted an&amp;nbsp;article which could&amp;nbsp;be useful for you.&lt;/p&gt; &lt;p&gt;&lt;A href="http://blogs.msdn.com/adarshk/articles/345411.aspx"&gt;http://blogs.msdn.com/adarshk/articles/345411.aspx&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in auto"&gt;This is first in the series, in future posting I promise to provide more details about specific scenarios which include Http with&amp;nbsp;authentication and&amp;nbsp;proxy server and also for other protocols like FtpWebRequest and SmtpClient, which were added in .net frameworks 2.0.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=345413" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>HttpWebRequest.GetResponse() gives "HTTP protocol violation" error after .net frameworks service packs</title><link>http://blogs.msdn.com/adarshk/archive/2004/11/08/254090.aspx</link><pubDate>Mon, 08 Nov 2004 20:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:254090</guid><dc:creator>adarshk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/254090.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=254090</wfw:commentRss><description>&lt;p&gt;This blog is valid for users of .Net frameworks 1.0 SP3 and .Net frameworks 1.1 SP1&lt;/p&gt; &lt;p&gt;The error is really because server is sending response with bad header format, which violates the http protocol specifications. These changes had been made to disallow bad headers.&amp;nbsp;Bad http header could cause&amp;nbsp;security vulnerability based on&amp;nbsp;response-splitting and other attacks based on misinterpreting HTTP streams.&amp;nbsp;&lt;/p&gt; &lt;p&gt;However if your application still need to deal with such responses, you could roll back to old bahavior of relaxed header parsing. You need to use following app.config file.&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&lt;font color="#000080"&gt;&lt;font face="Arial" color="#808080" size="3"&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;system.net&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;settings&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;httpWebRequest &lt;span class="hl"&gt;useUnsafeHeaderParsing&lt;/span&gt;="true"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/settings&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/system.net&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font color="#000080"&gt; &lt;p&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;&lt;font size="2"&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=254090" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>Using SSL client certificate in WebRequest and WebServices without certificate installation</title><link>http://blogs.msdn.com/adarshk/archive/2004/09/01/224214.aspx</link><pubDate>Wed, 01 Sep 2004 20:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:224214</guid><dc:creator>adarshk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/224214.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=224214</wfw:commentRss><description>&lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;If you are using .Net frameworks&amp;nbsp;1.0 or&amp;nbsp;1.1, certificate must be installed on either User store or Machine Store. This posting is only valid for v2.0.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;In version 2.0 (Currently released Whidbey Beta1) user have option to&amp;nbsp;use the certificate which contain the private key without installing it on certificate store.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;strong&gt;In general it is not recommended practice to store&amp;nbsp;certificate as file and not&amp;nbsp;install in certificate store. I&lt;/strong&gt;n some special cases user might not have access for certificate installation (e.g. Webbhosting site only allow ftp access to users). In such case you can store full certificate file (include private key) on a share and use it for client certiificate based SSL authentication.&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;font face="Times New Roman" color="#000000" size="3"&gt;&lt;font color="#000080"&gt;System.Security.Cryptography.X509Certificates&lt;/font&gt; &lt;/font&gt;namespace provide classes to create X509CertificateEx instance with private key persistence like below&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt;X509CertificateEx Cert = new X509CertificateEx();&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Arial" color="navy" size="1"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt;Cert.Import(_certificateFilieName,_certificatePassword,X509KeyStorageFlags.PersistKeySet);&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;font size="2"&gt;If you add&amp;nbsp;X509CertificateEx instance as mentioned above to&amp;nbsp;client certificate collection of HttpWebRequest or WebService instance, certificate base authentication&amp;nbsp;would work without&amp;nbsp;installing certificateon cetificate store&amp;nbsp;of the machine.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;font face="Arial" color="#800080" size="2"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt; &lt;p style="MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; mso-outline-level: 1"&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/font&gt; &lt;p class="MsoNormal"&gt;&lt;font face="Arial" color="navy" size="2"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=224214" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx">SSL</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/.Net+Frameworks+2.0/default.aspx">.Net Frameworks 2.0</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>Establishing cookie based session with WebServices and HttpWebRequest</title><link>http://blogs.msdn.com/adarshk/archive/2004/08/24/219714.aspx</link><pubDate>Tue, 24 Aug 2004 23:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:219714</guid><dc:creator>adarshk</dc:creator><slash:comments>75</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/219714.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=219714</wfw:commentRss><description>&lt;p&gt;&lt;font face="Arial" color="#000080" size="4"&gt;Create cookie based session with HttpWebRequest&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#000000" size="2"&gt;One common requirement for Http based application to maintain the session state within the application, if your http based application is using the System.Net.HttpWebRequest class, then you could use Cookiecontainer property to send and recieved the cookies. Important thing to note that you should create a single CookieContainer instance and use it across all applications&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#000000" size="2"&gt;Following example code snippet shows the sending and recieving the cookies from client application.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;CookieContainer myContainer = new CookieContainer();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;// following line will add a cookie in container, which would be&amp;nbsp;for all urls on the domain myDomainstr&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;myContainer.Add(new Cookie("name","value","/",myDomainstr)); &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;HttpWebRequest request1 = (HttpWebRequest) WebRequest.Create(httpUrlString);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;request1.CookieContainer = myContainer; // use this same container for all requests in your app&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;HttpWebResponse response = (HttpWebResponse) request.GetResponse(); //you can check&amp;nbsp;c&lt;/font&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;ookies on response.Cookies&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;..........&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;...........&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;HttpWebRequest request2 = (HttpWebRequest) WebRequest.Create(httpUrlString2);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;request2.CookieContainer = myContainer; //all relevant cookies recieved on request1 would be automatically included in request because of same Cookiecontainer instnce.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#a9a9a9" size="2"&gt;HttpWebResponse response = (HttpWebResponse) request.GetResponse();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" color="#000080" size="4"&gt;Create cookie based session with WebServices&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" color="#000000" size="2"&gt;If application want to&amp;nbsp;use WebServices with cookie based session variables to execute&amp;nbsp;service (ex. UserId of current ASP.Net session). This could be done via using the CookieContainer class&amp;nbsp;and no need to&amp;nbsp;add extra parameter inside the webservice call.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;Following code demonstrate the setting of userID on the webservice from client side, In this example &lt;span class="SpellE"&gt;&lt;font face="Courier New"&gt;adarshk_srv.RunSoap is the WebService proxy object on client side&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&lt;span class="SpellE"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span&gt;&lt;font face="Arial"&gt;&lt;font color="#a9a9a9"&gt;&lt;span class="GramE"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #666699; FONT-FAMILY: 'Courier New'"&gt;&lt;font color="#a9a9a9"&gt;adarshk_srv.RunSoap&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;span class="SpellE"&gt;RunService&lt;/span&gt; = new &lt;span class="SpellE"&gt;adarshk_srv.RunSoap&lt;/span&gt;();&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;font face="Arial"&gt;&lt;font color="#a9a9a9"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #666699; FONT-FAMILY: 'Courier New'"&gt;&lt;font color="#a9a9a9"&gt;RunService.CookieContainer&lt;/font&gt;&lt;/span&gt; = new &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;System.Net.CookieContainer&lt;/span&gt; &lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;font face="Arial"&gt;&lt;font color="#ffffff"&gt;&lt;span class="SpellE"&gt;&lt;font color="#a9a9a9"&gt;&lt;span class="GramE"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #666699; FONT-FAMILY: 'Courier New'"&gt;&lt;font color="#a9a9a9"&gt;RunService.CookieContainer.Add&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a9a9a9"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #666699; FONT-FAMILY: 'Courier New'"&gt;(&lt;/span&gt;new Uri(&lt;span class="SpellE"&gt;RunService.Url&lt;/span&gt;),&lt;/font&gt;&lt;span class="SpellE"&gt;&lt;font color="#a9a9a9"&gt;new &lt;span class="SpellE"&gt;&lt;span class="GramE"&gt;Cookie&lt;/span&gt; &lt;/span&gt;&lt;span class="GramE"&gt;(&lt;/span&gt;"userName",”adarshk");&lt;/font&gt;);&lt;/span&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;font face="Arial" color="#000000" size="2"&gt;On the server side WebService implementor could access the cookies send by the client from the HttpContext as shown below&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;if(Context.Request.Cookies != null &amp;amp;&amp;amp; context.Request.Cookies["userName"] == "adarshk")&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;{&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;// access data&amp;nbsp;specific to adarshk&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;}&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;else&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;{&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;// return the general data&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt;&lt;font color="#a9a9a9"&gt;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="COLOR: blue"&gt;&lt;o:p&gt; &lt;p style="MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-BOTTOM: 0px; VERTICAL-ALIGN: middle; mso-outline-level: 1"&gt;&lt;span style="COLOR: #333333; FONT-FAMILY: 'Trebuchet MS'"&gt;&lt;em&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=219714" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item><item><title>SSL https requests with client certificates from ASP.NET</title><link>http://blogs.msdn.com/adarshk/archive/2004/07/19/187667.aspx</link><pubDate>Mon, 19 Jul 2004 23:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:187667</guid><dc:creator>adarshk</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/187667.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=187667</wfw:commentRss><description>&lt;H1&gt;&lt;FONT face=Arial size=5&gt;Problem&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal&gt;Applications making https request from .net web applications (.aspx pages) are not able to use client certificates.&lt;/P&gt;
&lt;H1&gt;&lt;FONT face=Arial size=5&gt;Cause&lt;/FONT&gt;&lt;/H1&gt;
&lt;P class=MsoNormal&gt;Client certificates are linked to user accounts, ASPX is running under ASPNET account, this account can’t access the certificates installed under user account or system account.&lt;/P&gt;
&lt;P class=MsoNormal&gt;HttpWebRequest implementation only access the certificate only from account under which process is running or under System account. Most of the time when we install the certificate it is installed in current user account. &lt;/P&gt;
&lt;H1&gt;&lt;FONT face=Arial size=5&gt;Possible Solutions&lt;/FONT&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;a)&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Run the service under the account which certificate is installed, but in real world this is not a feasible solution on production servers,&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;SPAN&gt;b)&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Install the certificate under System account and provide access to ASPNET service account, this could be achieved using following steps&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;SPAN&gt;a.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Install certificate using MMC (Microsoft Management Console) or using certificate configuration tool as described in Microsoft KB article (&lt;A href="http://support.microsoft.com/?id=823193"&gt;&lt;FONT color=#0000ff&gt;http://support.microsoft.com/?id=823193&lt;/FONT&gt;&lt;/A&gt; )&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;SPAN&gt;b.&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Tool is available at the following link&lt;SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttpcertcfg_exe__a_certificate_configuration_tool.asp"&gt;&lt;FONT color=#0000ff&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttpcertcfg_exe__a_certificate_configuration_tool.asp&lt;/FONT&gt;&lt;/A&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;Make sure following, when installing the certificate&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;SPAN&gt;1)&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Certificate contains the private key, otherwise it can’t be used for client authentication, .cer certificate files only contain the public key, you need to have certificate with .pfx or .p12 file,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;SPAN&gt;2)&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Make sure you are installing certificate in “My” store of the system account, following command is an example of installing certificate in “My” store of “System” account with extending access to aspnet account, follow the above link for more detailed description and usage of certificate configuration tool&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;WinHttpCertCfg&amp;nbsp; -i mycert.pfx -p certpassword -c LOCAL_MACHINE\my –a aspnet&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal align=left&gt;&lt;FONT size=3&gt;&lt;FONT color=#000000&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal align=left&gt;&lt;FONT size=3&gt;&lt;FONT color=#000000&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN&gt;Note: Solution discussed here&amp;nbsp;would work on .Net frameworks v1.0 with SP3&amp;nbsp;or v1.1 with SP1 install, on previous versions of frameworks clientcertificate were used only from current User store not from System acount.&lt;/SPAN&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;SPAN&gt;&lt;o:p&gt;&lt;FONT size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;EM&gt;This posting is provided "AS IS" with no warranties, and confers no rights&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P class=MsoNormal&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=187667" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/adarshk/archive/tags/Net+class+library/default.aspx">Net class library</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx">SSL</category><category domain="http://blogs.msdn.com/adarshk/archive/tags/HttpWebRequest/default.aspx">HttpWebRequest</category></item></channel></rss>