<?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>“Geneva” Team Blog : certificate chain</title><link>http://blogs.msdn.com/card/archive/tags/certificate+chain/default.aspx</link><description>Tags: certificate chain</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>CardSpace Certificate Chain Validation Issue with Intermediate Certificates</title><link>http://blogs.msdn.com/card/archive/2008/03/21/cardspace-certificate-chain-validation-issue-with-intermediate-certificates.aspx</link><pubDate>Fri, 21 Mar 2008 09:46:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8328627</guid><dc:creator>CardSpaceBlog</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/card/comments/8328627.aspx</comments><wfw:commentRss>http://blogs.msdn.com/card/commentrss.aspx?PostID=8328627</wfw:commentRss><description>&lt;p&gt;&lt;font face="v" size="2"&gt;One problem with the original version of CardSpace was that it seemed to reject some legitimate SSL sites, but like all tricky bugs, it didn&amp;#8217;t happen consistently enough to be caught in the first release. What was going on was that sometimes CardSpace couldn&amp;#8217;t validate the intermediate certificates in the certificate chain because of a disconnect with the browser&amp;#8217;s certificate store. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;If intermediate certificates aren&amp;#8217;t installed on a user&amp;#8217;s computer, most browsers use the certificate obtained from the site to reconstruct the whole chain and show the user they are at an SSL site. CardSpace, as it turns out, was not able to get the missing certificates.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Since, this bug could make a legitimate site appear to be fraudulent in CardSpace and because the behavior is intermittent, it might be missed by a web developer adding support for Information Cards to their site.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;We asked the IE team and the maintainers of the &lt;/font&gt;&lt;a href="http://www.codeplex.com/IdentitySelector"&gt;&lt;font face="v" size="2"&gt;browser add-on for Firefox&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; to enable CardSpace to retrieve the correct certificate, and they did. The update to IE was included in the &lt;/font&gt;&lt;a href="http://blogs.msdn.com/ie/archive/2007/10/09/ie-october-security-update-is-now-available.aspx"&gt;&lt;font face="v" size="2"&gt;October 2007 IE Security Update&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; and the updated Firefox add-on can be &lt;/font&gt;&lt;a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IdentitySelector&amp;amp;ReleaseId=11863"&gt;&lt;font face="v" size="2"&gt;downloaded here&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; (thanks &lt;/font&gt;&lt;a href="http://ignisvulpis.blogspot.com/2008/03/certificate-chain-verification-for.html"&gt;&lt;font face="v" size="2"&gt;Axel&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt;!). Implementers of other Identity Selectors should consider whether this issue is present in their code as well. I&amp;#8217;ll hand off now to Shan to explain more details about the problem and the fix.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Rob Franco     &lt;br /&gt;Lead Program Manager &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;CardSpace&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;========&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;Introduction &amp;#8211; How the recipient certificate &amp;amp; its intermediates are retrieved by the browser&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;When a client navigates to a (https) site in a browser, there is a SSL handshake by the browser with the site. This handshake involves the client receiving the &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font face="v" size="2"&gt;certificate of the site, and&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font face="v" size="2"&gt;any intermediate certificates, if any, that are part of the recipient certificate&amp;#8217;s issuer chain.&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;The intermediate certificates (if any) are necessary to build the certificate chain&amp;#160; to a trusted root CA for purposes of certificate validation. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Note that CardSpace does an independent validation of the recipient certificate, in addition to the browser. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;Why CardSpace certificate validation in .NET 3.0 would fail when intermediate certificates are not present on the client machine&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;When CardSpace was being invoked by the browser, the intermediate certificates received during the browser SSL handshake were not passed to CardSpace. Only the leaf certificate was passed in. Since the intermediate certificates were not passed in (and CardSpace did not have a mechanism to receive them), the only way for the chain to be built (and validated) successfully by CardSpace was if the intermediates were already present in the local Intermediate certificate store.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Therefore, when intermediate certificates were NOT present on the client machine, CardSpace validation of the recipient certificate would fail even though the site actually chained up to a trusted CA (and showed up fine within the browser). &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;A possible workaround for this issue&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;A potential workaround for this problem is to have relying parties certificates utilize the Authority Information Access (AIA) extension (with accesMethod=cAIssuers). This extension, added by CAs in the issued certificates, allows certificate verifiers to retrieve the issuing certificates when intermediate certificates are not present in the verification environment. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;However, it may not be judicious to overly depend on the AIA infrastructure as a workaround for this issue. This is because CAs may not choose to include this extension. In addition, it is often unreliable, especially with enterprise CAs.&amp;#160; For example, the URL specified in the AIA extension might be invalid or unreachable. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;How have we fixed this issue in the .NET Framework 3.0 SP1 version of CardSpace&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;The CardSpace team has made a fix in the .NET Framework 3.0 SP1 (which ships as part of .NET 3.5) to address this issue. This change enables the Internet Explorer module (or other browser add-ons) to pass the intermediate certificates that were retrieved during the SSL handshake into CardSpace. These intermediate certificates are then used by CardSpace for chain building and validation.&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;To accomplish this fix, we have added a new version of the recipient-policy struct, namely RECIPIENTPOLICY2 to the updated version of CardSpace API &amp;#8220;GetBrowserToken&amp;#8221;. The old version of the struct, RECIPIENTPOLICY, which only passes the leaf certificate information, should be considered deprecated.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="v"&gt;At the same time, the Internet Explorer (IE) module that communicates with CardSpace to pass certificate information from the browser to CardSpace has been updated to provide the complete certificate chain to CardSpace. This update comes in &lt;b&gt;the &lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;a href="http://blogs.msdn.com/ie/archive/2007/10/09/ie-october-security-update-is-now-available.aspx"&gt;&lt;font face="v" size="2"&gt;October 2007 IE Security Update&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="v"&gt;Other Information Card browser add-ons written to invoke CardSpace should also be updated to take advantage of this fix.&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;Some notes for sites using CardSpace&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;If you are using CardSpace, you do not have to worry about this issue, assuming your clients will be running the &lt;/font&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6"&gt;&lt;font face="v" size="2"&gt;.NET Framework 3.5&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; AND have the latest IE updates (if they are running IE) or have a version of &lt;/font&gt;&lt;a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IdentitySelector&amp;amp;ReleaseId=11863"&gt;&lt;font face="v" size="2"&gt;the Firefox add-on that takes advantage of the fix&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;You can check for the right version of CardSpace by checking the user agent string for the following token:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="v"&gt;Updated CardSpace (.Net 3.5) = &lt;b&gt;&amp;#8220;&lt;/b&gt;&lt;b&gt;.NET CLR 3.5.21022&amp;#8221;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font face="v" size="2"&gt;Details of the fix for browser add-on developers written to invoke CardSpace &lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="v"&gt;&lt;i&gt;(If you are simply a site using CardSpace, then the below section on how to invoke the GetBrowserToken API with the new structures does NOT apply to you)&lt;/i&gt;        &lt;br /&gt;As mentioned previously, we have added a new version of the recipient-policy struct, namely RECIPIENTPOLICY2 to the updated version of CardSpace API &amp;#8220;GetBrowserToken&amp;#8221;:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;HRESULT&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;CARDSPACECALL GetBrowserToken(&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;__in DWORD dwParamType,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;__in PVOID pParam,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;__out_opt DWORD* pcbToken,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;__out_bcount_opt(*pcbToken) PBYTE* ppToken );&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;This function is currently documented in MSDN: &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa702769.aspx"&gt;&lt;font face="v" size="2"&gt;http://msdn2.microsoft.com/en-us/library/aa702769.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; ) though it has not yet been updated with the .NET 3.5 changes.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;To utilize the intermediate certificate fix in .NET 3.5, i.e. to invoke CardSpace passing in the intermediate certificates of the recipient, you would invoke the API in this following way:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font face="v" size="2"&gt;dwParamType should be set to value RECIPIENTPOLICYV2 (which is really value 2) &lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font face="v" size="2"&gt;pParam should point to a RECIPIENTPOLICY2 structure (see below) &lt;/font&gt;      &lt;ul&gt;       &lt;li&gt;&lt;font face="v" size="2"&gt;For the ENDPOINTADDRESS2, &lt;/font&gt;          &lt;ul&gt;           &lt;li&gt;&lt;font face="v" size="2"&gt;DWORD identityType should be set to 2 &lt;/font&gt;&lt;/li&gt;            &lt;li&gt;&lt;font face="v" size="2"&gt;PVOID identityBytes should be set to a CERTIFICATE_CHAIN_BLOB &lt;/font&gt;              &lt;ul&gt;               &lt;li&gt;&lt;font face="v" size="2"&gt;DATA_BLOB rawCertificates should contain (see struct definition from wincrypt.h below) &lt;/font&gt;                  &lt;ul&gt;                   &lt;li&gt;&lt;font face="v" size="2"&gt;Count of certificates &lt;/font&gt;&lt;/li&gt;                    &lt;li&gt;&lt;font face="v" size="2"&gt;Bytes of each certificate of the certificate chain retrieved by invoking &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa376569.aspx"&gt;&lt;font face="v" size="2"&gt;CertSerializeCertificateStoreElement&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt; (which retrieves the bytes of each certificate in the chain in DER encoded form) &lt;/font&gt;&lt;/li&gt;                    &lt;li&gt;&lt;font face="v" size="2"&gt;Note that the recipient certificate is assumed to be the 0&lt;sup&gt;th&lt;/sup&gt; (zeroth&lt;u&gt;)&lt;/u&gt; element of this array, followed by its issuer at index 1 (one) etc., followed by the issuer of the issuer at index 2 (two) and so on. &lt;/font&gt;&lt;/li&gt;                 &lt;/ul&gt;               &lt;/li&gt;             &lt;/ul&gt;           &lt;/li&gt;         &lt;/ul&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;When invoking CardSpace in the &lt;/font&gt;&lt;a href="http://blogs.msdn.com/card/archive/2007/09/25/deploy-cardspace-on-your-site-without-a-ssl-certificate.aspx"&gt;&lt;font face="v" size="2"&gt;no-SSL case&lt;/font&gt;&lt;/a&gt;&lt;font face="v" size="2"&gt;, the identityBytes pointer in the ENDPOINTADDRESS2 structure should be NULL.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;typedef struct _RECIPIENTPOLICY2&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;{&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;font face="v"&gt;ENDPOINTADDRESS2&lt;sup&gt; r&lt;/sup&gt;ecipient&lt;u&gt;;&lt;/u&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;ENDPOINTADDRESS2 issuer;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;LPCWSTR tokenType;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;CLAIMLIST requiredClaims;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;CLAIMLIST optionalClaims;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;LPCWSTR privacyUrl;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;UINT privacyVersion;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;}RECIPIENTPOLICY2, *PRECIPIENTPOLICY2;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;typedef struct _ENDPOINTADDRESS2&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;{&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;LPCWSTR serviceUrl;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;LPCWSTR policyUrl;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;DWORD identityType;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;PVOID identityBytes;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;}ENDPOINTADDRESS2, *PENDPOINTADDRESS2;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;typedef struct _CERTIFICATE_CHAIN_BLOB&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;{&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;DWORD certCount;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;DATA_BLOB* rawCertificates;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;}CERTIFICATE_CHAIN_BLOB, *PCERTIFICATE_CHAIN_BLOB;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;typedef struct _CRYPTOAPI_BLOB {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;DWORD cbData;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;BYTE *pbData;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;} DATA_BLOB, *PDATA_BLOB,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;NOTE: If your clients do not have the have the updated (.NET 3.5) CardSpace bits, then calling the &amp;quot;GetBrowserToken&amp;quot; API with the new RECIPENTPOLICY2 struct would yield E_INVALIDARG for HRESULT. Therefore if you are a browser add-on developer and do not intend to break .NET 3.0 clients then you would check whether .NET 3.5 is installed before invoking the API with the new RECIPENTPOLICY2 struct.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;You can do this by checking for the presence of this key:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;[HKEY_LOCAL_MACHINE\Software\ Microsoft\NET Framework Setup\NDP\v3.5]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;&amp;quot;Install&amp;quot;=dword:00000001&amp;quot; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;If the key does not exist then you would resort to using the original RECIPENTPOLICY struct.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;---------------------------------------------------------------------------------------------------------------&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;We hope this fix helps you keep CardSpace running problem free with your sites!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Sudarshan [Shan] Sundar&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;Software Development Engineer,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="v" size="2"&gt;CardSpace Team&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8328627" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/card/archive/tags/CardSpace/default.aspx">CardSpace</category><category domain="http://blogs.msdn.com/card/archive/tags/certificate+chain/default.aspx">certificate chain</category></item></channel></rss>