<?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 : SSL</title><link>http://blogs.msdn.com/adarshk/archive/tags/SSL/default.aspx</link><description>Tags: SSL</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using FtpWebRequest to do FTP over SSL</title><link>http://blogs.msdn.com/adarshk/archive/2005/04/22/410925.aspx</link><pubDate>Fri, 22 Apr 2005 23:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:410925</guid><dc:creator>adarshk</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/410925.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=410925</wfw:commentRss><description>&lt;P&gt;Last few weeks we were busy to get Whidbey Beta-2 bits ready for release.&lt;/P&gt;
&lt;P&gt;If you are looking for some API where your&amp;nbsp;application could talk to a FTP server, which supports SSL. FtpWebRequest under System.Net namespace is your solution. Here I will just point to SSL specific features of the class&lt;/P&gt;
&lt;P&gt;Enabling FtpWebrequest to use Ssl is pretty simple, you just need to set EnableSsl flag before calling GetResponse() or GetRequestStream() on the FtpWebRequest object.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;FtpWebRequest request = WebRequest.Create(&lt;/FONT&gt;&lt;A href="ftp://myftpserver/dir/filename"&gt;&lt;FONT color=#808080 size=2&gt;ftp://myftpserver/dir/filename&lt;/FONT&gt;&lt;/A&gt;&lt;FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#808080&gt;);&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;request.Method = WebRequestMethods.Ftp.DownloadFile;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;request.EnableSsl = true; // Here you enabled request to use ssl instead of clear text&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#808080&gt;WebResponse response = request.GetResponse();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Some people asked me why FtpWebRequest support "ftps:" protocol&amp;nbsp;based uri similar to "https:", the reason is there is no standard "ftps" scheme specified (yet) and ftp-over-ssl mechanism&amp;nbsp;actually does not demand dedicated port for ssl, you could&amp;nbsp;do it&amp;nbsp;on the same server port on which you are doing regular clear text ftp.&amp;nbsp;It depends on server configuration choice to force the SSL or allow both.&lt;/P&gt;
&lt;P&gt;Once you start doing Ftp over SSL there are two important things you will need to know&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;Validating Server Certificate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;If you were old WebRequest user, you might already know about using ServicePointManager.CertificatePolicy for https server certificate validation. In whidbey you will notice the compiler warning saying ServicePointManager.CertificatePolicy is obsolete and replaced with ServicePointManager.ServerCertificateValidationCallback which is delegate of type RemoteCertificateValidationDelegate. New delegate provide better programming model with all certificate errors reported in a single callback and you will also get instance of X509Chain object, which allow you to make decision on certificate chain.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT size=2&gt;ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(myCertificateValidation);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&lt;FONT&gt;&lt;FONT color=#000000 size=2&gt;Actual method will look as below&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&lt;FONT size=2&gt;public bool myCertificateValidation(Object sender, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;X509Certificate cert, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;X509Chain chain, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SslPolicyErrors Errors)&lt;BR&gt;{ return&amp;nbsp;(certificate.GetName() == "my_trusted_name");&amp;nbsp;}; //Just an example, not real world scenaio&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;:) Another&amp;nbsp;additional advantage you can take with delegate is from anonymous method support of C# 2.0, especially if you have very simple 1-2 line certificateplicy to implement, see follwing example.&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080&gt;&lt;FONT size=2&gt;ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj,&amp;nbsp;X509Certificate certificate,&amp;nbsp;X509Chain chain,&amp;nbsp;SslPolicyErrors errors)&amp;nbsp;&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;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;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;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;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;nbsp;&amp;nbsp;&amp;nbsp;{ return&amp;nbsp;(certificate.GetName() == "my_trusted_name");&amp;nbsp;}; //Just an example, not real world scenaio&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;Using Client Certificate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Using Client certificate based authentication when connecting to&amp;nbsp;FTP-SSL is no different then existing HttpWebRequest. You just need to assign appropriate X509Certificate instance to the request object before making GetResponse() or GetRequestStream() call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#808080 size=2&gt;&lt;SPAN&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;img src="http://blogs.msdn.com/aggbug.aspx?PostID=410925" 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/FtpWebRequest/default.aspx">FtpWebRequest</category></item><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>Configure System.Net.HttpListener to listen for SSL</title><link>http://blogs.msdn.com/adarshk/archive/2004/11/10/255467.aspx</link><pubDate>Thu, 11 Nov 2004 03:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:255467</guid><dc:creator>adarshk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/adarshk/comments/255467.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adarshk/commentrss.aspx?PostID=255467</wfw:commentRss><description>&lt;p&gt;&lt;font size="3"&gt;Whidbey contains cool class HttpListener under System.Net namespace, it allows you to create your your own HttpServer on top of HttpSys. Some of you aske about&amp;nbsp;steps for configuring HttpListener to work with SSL. Basically you need to configure httpsys. You need to&amp;nbsp; bound particular port to a server certificate, where you want your listener to listen&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;1) &amp;nbsp;install the server certificate in machine store – you can manually install certificate using mmc&amp;nbsp;(Alternatively you can also use winhttpcertcfg command line tool, which is available with win32 SDK install)&lt;br /&gt;&lt;br /&gt;2) next step is to bind the port to use this certificate, this could be done using httpcfg tool (Also a part of win32 sdk), following example&amp;nbsp;demonstrate&amp;nbsp;configuration for port 9443&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Command line with no client certificate authentication&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt; httpcfg.exe set &lt;span class="hl"&gt;ssl&lt;/span&gt; -i 0.0.0.0:9443 -c "MY" -h &amp;lt;Certificate Hash&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Command line with client certificate authentication&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt; httpcfg.exe set &lt;span class="hl"&gt;ssl&lt;/span&gt; -i 0.0.0.0:9443 -f 2 -c "MY" -h &amp;lt;Certificate Hash&amp;gt;&lt;/font&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;To know more about System.Net.HttpListener, check the System.Net Whidbey documentation&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn2.microsoft.com/library/btdf6a7e.aspx"&gt;http://msdn2.microsoft.com/library/btdf6a7e.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;To know more about &lt;font size="2"&gt;winhttpcertcfg.exe and httpcfg.exe, you could follow the following links,&lt;/font&gt;&lt;/p&gt; &lt;p&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;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winhttp/http/winhttpcertcfg_exe__a_certificate_configuration_tool.asp&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http/http/httpcfg_exe.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/http/http/httpcfg_exe.asp&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&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;img src="http://blogs.msdn.com/aggbug.aspx?PostID=255467" width="1" height="1"&gt;</description><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></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>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>