<?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>WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx</link><description>There are a number of authentication techniques supported by WCF. For instance Windows Authentication, X509 Certificates, Issued Tokens, and Username and Password are all mechanisms that can be used for authentication. These client credential types are</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Techy News Blog &amp;raquo; WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#5296018</link><pubDate>Fri, 05 Oct 2007 19:53:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5296018</guid><dc:creator>Techy News Blog » WCF Authentication: Custom Username and Password Validator</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.artofbam.com/wordpress/?p=5519"&gt;http://www.artofbam.com/wordpress/?p=5519&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#5649301</link><pubDate>Wed, 24 Oct 2007 15:51:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5649301</guid><dc:creator>JanW</dc:creator><description>&lt;p&gt;Thanks for the guide. However, one of the issues here is that any exceptions thrown in the Validate() method will not be reported back to the client properly. All you will get is a MessageSecurityException. This has been reported several times (e.g. here: &lt;a rel="nofollow" target="_new" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=575748&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=575748&amp;amp;SiteID=1&lt;/a&gt;) Unfortunatley Microsoft did not come up with an adequate response yet.&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#6573121</link><pubDate>Wed, 28 Nov 2007 11:31:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6573121</guid><dc:creator>Jon</dc:creator><description>&lt;p&gt;I created a certificate &amp;quot;CN=SignedByCA&amp;quot; and updated the App.Config files to refer to its thumbprint. Now when I try to start the host, I get the following exception on host.Open():&lt;/p&gt;
&lt;p&gt;The certificate 'CN=SignedByCA' must have a private key that is capable of key exchange. The process must have access rights for the private key.&lt;/p&gt;
&lt;p&gt;I'm not sure how to give the host access to the private key. I'm starting the host process using VS 2008.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Jon&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#7061696</link><pubDate>Thu, 10 Jan 2008 22:43:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7061696</guid><dc:creator>Diego</dc:creator><description>&lt;p&gt;I'm having the same issue Jon mentioned. I'm also getting the message:&lt;/p&gt;
&lt;p&gt;The certificate 'CN=SignedByCA' must have a private key that is capable of key exchange. The process must have access rights for the private key.&lt;/p&gt;
&lt;p&gt;Please.... help :S&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#7364003</link><pubDate>Fri, 01 Feb 2008 05:04:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7364003</guid><dc:creator>Dimitris-Ilias Gkanatsios</dc:creator><description>&lt;p&gt;To the two above: Use the FindPrivateKey utility located in the WCF samples to find the location of the private key, and then set the permissions accordingly.&lt;/p&gt;
&lt;p&gt;I spent many hours today while having the same problem, and I came up with the following solution &lt;/p&gt;
&lt;p&gt;To install a self signed certificate&lt;/p&gt;
&lt;p&gt;makecert.exe -sr LocalMachine -ss MY -a sha1 -n CN=%SERVER_NAME% -sky exchange -pe&lt;/p&gt;
&lt;p&gt;certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r LocalMachine -s TrustedPeople&lt;/p&gt;
&lt;p&gt;To use the FindKeyUtility&lt;/p&gt;
&lt;p&gt;FindPrivateKey.exe TrustedPeople LocalMachine Private key directory: C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys Private key file name: 756e9ecb7bb8ed83bf80031497479997_8a4ee4f0-1f8d-4d2e-b1bf-fff1d5b15e61&lt;/p&gt;
&lt;p&gt;And then, you can go to the specified folder and change the permissions...&lt;/p&gt;
&lt;p&gt;Moreover, I needed to set this in the client's config file&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;lt;behaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;endpointBehaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;behavior name=&amp;quot;ClientCertificateBehavior&amp;quot;&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;clientCredentials&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;serviceCertificate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;authentication certificateValidationMode=&amp;quot;PeerOrChainTrust&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/serviceCertificate&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/clientCredentials&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/behavior&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/endpointBehaviors&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/behaviors&amp;gt;&lt;/p&gt;
&lt;p&gt;and add this to the endpoint configuration&lt;/p&gt;
&lt;p&gt;behaviorConfiguration=&amp;quot;ClientCertificateBehavior&amp;quot;&lt;/p&gt;
&lt;p&gt;Finally, pay attention to the &lt;/p&gt;
&lt;p&gt;&amp;lt;identity&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;dns value=&amp;quot;localhost&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/identity&amp;gt;&lt;/p&gt;
&lt;p&gt;element, in the client.&lt;/p&gt;
&lt;p&gt;The dns value must much the one in the certificate.&lt;/p&gt;
&lt;p&gt;Good luck!!&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#7374680</link><pubDate>Fri, 01 Feb 2008 17:00:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7374680</guid><dc:creator>Thiarley Fontenele</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If I authenticate the user using peertrust, How can I get his certificate inside the Operation Contract ?&lt;/p&gt;
&lt;p&gt;I need the certificate to get others informations.&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8153151</link><pubDate>Tue, 11 Mar 2008 17:19:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8153151</guid><dc:creator>Jernej Logar</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I was also getting the message:&lt;/p&gt;
&lt;p&gt;The certificate 'CN=SignedByCA' must have a private key that is capable of key exchange. The process must have access rights for the private key.&lt;/p&gt;
&lt;p&gt;I solved that by importing the certificate together with the private key, using a pfx fiel which I generated wtih pvk2pfx.&lt;/p&gt;</description></item><item><title>WCF Security Resources</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8410946</link><pubDate>Sun, 20 Apr 2008 07:28:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8410946</guid><dc:creator>alik levin's</dc:creator><description>&lt;p&gt;This is a digest of WCF Security resources I was collecting for some time. Drop me a comment in case&lt;/p&gt;
</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8487609</link><pubDate>Sun, 11 May 2008 18:25:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8487609</guid><dc:creator>Fernando Alves</dc:creator><description>&lt;p&gt;In some of my implemented OperationContract methods i need to log with others method informations, and console output the validated credentials (username/password), how can i get the respective instanciated credential values?&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8487775</link><pubDate>Sun, 11 May 2008 19:18:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8487775</guid><dc:creator>Fernando Alves</dc:creator><description>&lt;p&gt;Nevermind, ServiceSecurityContext.Current.PrimaryIdentity.Name&lt;/p&gt;</description></item><item><title>WCF Security Resources(转)</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8487797</link><pubDate>Sun, 11 May 2008 19:22:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8487797</guid><dc:creator>江南白衣</dc:creator><description>&lt;p&gt;This is a digest of WCF Security resources I was collecting for some time. Drop me a comment in case it is useful.&lt;/p&gt;
</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8742953</link><pubDate>Thu, 17 Jul 2008 12:08:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8742953</guid><dc:creator>Arjan Hordijk</dc:creator><description>&lt;p&gt;I had the same problem. &lt;/p&gt;
&lt;p&gt;These were the steps I took to solve the problem:&lt;/p&gt;
&lt;p&gt;I removed the generated personal key from the store and issued the following request: makecert -sk SignedByCA -iv TempCA.pvk -n &amp;quot;CN=localhost&amp;quot; -ic TempCA.cer SignedByCA.cer -sr LocalMachine -ss My -sky exchange -pe&lt;/p&gt;
&lt;p&gt;The created certificate was added to the personal certifcate store of the local computer. &lt;/p&gt;
&lt;p&gt;After placing this certificate in the personal certificate store of the current user (drag and drop) the error was gone.&lt;/p&gt;
&lt;p&gt;Hope this will help.....&lt;/p&gt;
&lt;p&gt;We are not the only ones (Also see this post: &lt;a rel="nofollow" target="_new" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1180892&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1180892&amp;amp;SiteID=1&lt;/a&gt;)&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8767672</link><pubDate>Wed, 23 Jul 2008 23:39:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8767672</guid><dc:creator>Mathew Upchurch</dc:creator><description>&lt;p&gt;Great article but my problem is I'm authenticated on my web site already (setting the generic principal)... not I need to call my services layer... but I no longer have password available... &amp;nbsp;any best practices for how to deal with this?&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8769698</link><pubDate>Thu, 24 Jul 2008 20:55:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8769698</guid><dc:creator>VG</dc:creator><description>&lt;p&gt;My Service is hosted under IIS with SSL enabled.&lt;/p&gt;
&lt;p&gt;This works without SSL enabled, but doesn't work with SSL on.&lt;/p&gt;
&lt;p&gt;Any tips?&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8865737</link><pubDate>Thu, 14 Aug 2008 11:40:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8865737</guid><dc:creator>John Doe</dc:creator><description>&lt;p&gt;Good post.&lt;/p&gt;
&lt;p&gt;Complemented with &lt;a rel="nofollow" target="_new" href="http://www.digwin.com/view/howto-use-makecert-for-trusted-root-certification-authority-and-ssl-certificate-issuance"&gt;http://www.digwin.com/view/howto-use-makecert-for-trusted-root-certification-authority-and-ssl-certificate-issuance&lt;/a&gt; , it made for an easy implementation of UserName validation. : )&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#8962030</link><pubDate>Tue, 23 Sep 2008 11:22:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8962030</guid><dc:creator>angeltq</dc:creator><description>&lt;p&gt;Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'CurrentUser', FindType 'FindByThumbprint', FindValue '8e f9 c6 6f 4e a0 0c 49 4f 84 69 fb de c6 a7 e1 79 01 5b 6e'.&lt;/p&gt;
&lt;p&gt;Help me!&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9119372</link><pubDate>Tue, 18 Nov 2008 20:27:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9119372</guid><dc:creator>Gr1nch</dc:creator><description>&lt;p&gt;Anyone know how to catch any exception we throw in our Validate() function so we might have some means of returning a code for why validation failed? It would seem that regardless of what SecurityTokenException I throw, the only exception actually caught on the client side is the generic one. I can see my exception if I run diagnostics, but I need the client to see it to detect such things as lockout and other failure reasons...&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9573933</link><pubDate>Tue, 28 Apr 2009 20:59:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9573933</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;2 Gr1nch&lt;/p&gt;
&lt;p&gt;1) Throw a FaultException from Validate(...)&lt;/p&gt;
&lt;p&gt;2) Catch MessageSecurityException on the client.&lt;/p&gt;
&lt;p&gt;3) In the InnerException property you will find the FaultException you threw.&lt;/p&gt;
&lt;p&gt;Keep in mind: generic FaultExceptions don't work here as a filter on client side, but you can, for example, use FaultCode during FaultException initialization to be sure that an InnerException the client got from MessageSecurityException is indeed the exception you threw in Validate(...).&lt;/p&gt;</description></item><item><title>#.think.in infoDose #28 (29th Apr - 8th May)</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9618092</link><pubDate>Fri, 15 May 2009 11:32:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9618092</guid><dc:creator>#.think.in</dc:creator><description>&lt;p&gt;#.think.in infoDose #28 (29th Apr - 8th May)&lt;/p&gt;
</description></item><item><title>#.think.in infoDose #28 (29th Apr - 8th May)</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9666479</link><pubDate>Sun, 31 May 2009 01:12:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9666479</guid><dc:creator>#.think.in</dc:creator><description>&lt;p&gt;#.think.in infoDose #28 (29th Apr - 8th May)&lt;/p&gt;
</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9907331</link><pubDate>Wed, 14 Oct 2009 21:28:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9907331</guid><dc:creator>Thankful</dc:creator><description>&lt;p&gt;Exactly what I needed!!!&lt;/p&gt;
&lt;p&gt;Thanks a whole lot for the post.&lt;/p&gt;</description></item><item><title>re: WCF Authentication: Custom Username and Password Validator</title><link>http://blogs.msdn.com/pedram/archive/2007/10/05/wcf-authentication-custom-username-and-password-validator.aspx#9916615</link><pubDate>Tue, 03 Nov 2009 07:28:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916615</guid><dc:creator>Karan</dc:creator><description>&lt;p&gt;Hi, I am getting this exception as described in the test above.&lt;/p&gt;
&lt;p&gt;“Identity check failed for outgoing message. The expected DNS identity of the remote endpoint was 'X' but the remote endpoint provided DNS claim 'Y'. If this is a legitimate remote endpoint, you can fix the problem by explicitly specifying DNS identity 'Y' as the Identity property of EndpointAddress when creating channel proxy.”&lt;/p&gt;
&lt;p&gt;I am using an endpoint identity as SPN. Any idea how to get this to work with endpoint Identity set as SPN.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;</description></item></channel></rss>