<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Extracting X509 Extensions from a CSR using the Bouncy Castle APIs</title>
	<atom:link href="http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/feed/" rel="self" type="application/rss+xml" />
	<link>http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/</link>
	<description>the home of peter chng</description>
	<lastBuildDate>Tue, 22 May 2012 03:36:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: TheFonz</title>
		<link>http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/comment-page-1/#comment-316713</link>
		<dc:creator>TheFonz</dc:creator>
		<pubDate>Thu, 23 Feb 2012 16:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://unitstep.net/?p=407#comment-316713</guid>
		<description>Thanks you are life saver!!!!!
The C# version below... Cant believe how badly documented the BouncyCastle libraries are...

&lt;code&gt;
X509Extensions GetX509ExtensionsFromCsr( Pkcs10CertificationRequest certificateSigningRequest ) 
   {
       CertificationRequestInfo certificationRequestInfo = certificateSigningRequest.GetCertificationRequestInfo();

      Asn1Set attributesAsn1Set = certificationRequestInfo.Attributes;

      // The `Extension Request` attribute is contained within an ASN.1 Set,
      // usually as the first element.
      X509Extensions certificateRequestExtensions = null;
      for (int i = 0; i = 1)
                 {
                     KeyValuePair pair = MakeX509Extensions((Asn1Sequence)attributeValues[0]);
                     certificateRequestExtensions = new X509Extensions(pair.Key, pair.Value);
                     // No need to search any more.
                     break;
                 }
             }
         }
         else if (derEncodable is Org.BouncyCastle.Asn1.Cms.Attribute)
         {
             Org.BouncyCastle.Asn1.Cms.Attribute attribute = (Org.BouncyCastle.Asn1.Cms.Attribute)derEncodable;

             if (attribute.AttrType.Equals(PkcsObjectIdentifiers.Pkcs9AtExtensionRequest))
             {
                 // The `Extension Request` attribute is present.
                 Asn1Set attributeValues = attribute.AttrValues;

                 // The X509Extensions are contained as a value of the ASN.1 Set.
                 // Assume that it is the first value of the set.
                 if (attributeValues.Count &gt;= 1)
                 {
                     certificateRequestExtensions = (X509Extensions)attributeValues[0];
                     // No need to search any more.
                     break;
                 }
             }
         }
      }

      if (null == certificateRequestExtensions)
      {
          throw new Exception(&quot;Could not obtain X509 Extensions from the CSR&quot;);
      }
      return certificateRequestExtensions;
   }
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Thanks you are life saver!!!!!<br />
The C# version below&#8230; Cant believe how badly documented the BouncyCastle libraries are&#8230;</p>
<p><code><br />
X509Extensions GetX509ExtensionsFromCsr( Pkcs10CertificationRequest certificateSigningRequest )<br />
   {<br />
       CertificationRequestInfo certificationRequestInfo = certificateSigningRequest.GetCertificationRequestInfo();</p>
<p>      Asn1Set attributesAsn1Set = certificationRequestInfo.Attributes;</p>
<p>      // The `Extension Request` attribute is contained within an ASN.1 Set,<br />
      // usually as the first element.<br />
      X509Extensions certificateRequestExtensions = null;<br />
      for (int i = 0; i = 1)<br />
                 {<br />
                     KeyValuePair pair = MakeX509Extensions((Asn1Sequence)attributeValues[0]);<br />
                     certificateRequestExtensions = new X509Extensions(pair.Key, pair.Value);<br />
                     // No need to search any more.<br />
                     break;<br />
                 }<br />
             }<br />
         }<br />
         else if (derEncodable is Org.BouncyCastle.Asn1.Cms.Attribute)<br />
         {<br />
             Org.BouncyCastle.Asn1.Cms.Attribute attribute = (Org.BouncyCastle.Asn1.Cms.Attribute)derEncodable;</p>
<p>             if (attribute.AttrType.Equals(PkcsObjectIdentifiers.Pkcs9AtExtensionRequest))<br />
             {<br />
                 // The `Extension Request` attribute is present.<br />
                 Asn1Set attributeValues = attribute.AttrValues;</p>
<p>                 // The X509Extensions are contained as a value of the ASN.1 Set.<br />
                 // Assume that it is the first value of the set.<br />
                 if (attributeValues.Count &gt;= 1)<br />
                 {<br />
                     certificateRequestExtensions = (X509Extensions)attributeValues[0];<br />
                     // No need to search any more.<br />
                     break;<br />
                 }<br />
             }<br />
         }<br />
      }</p>
<p>      if (null == certificateRequestExtensions)<br />
      {<br />
          throw new Exception("Could not obtain X509 Extensions from the CSR");<br />
      }<br />
      return certificateRequestExtensions;<br />
   }<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohd Ekmal</title>
		<link>http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/comment-page-1/#comment-165827</link>
		<dc:creator>Mohd Ekmal</dc:creator>
		<pubDate>Tue, 23 Jun 2009 03:04:35 +0000</pubDate>
		<guid isPermaLink="false">http://unitstep.net/?p=407#comment-165827</guid>
		<description>Thanks man This example really help me.</description>
		<content:encoded><![CDATA[<p>Thanks man This example really help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Chng</title>
		<link>http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/comment-page-1/#comment-156702</link>
		<dc:creator>Peter Chng</dc:creator>
		<pubDate>Fri, 17 Apr 2009 02:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://unitstep.net/?p=407#comment-156702</guid>
		<description>@hemant
Unfortunately, I don&#039;t really have any practical C# experience so I wouldn&#039;t be able to provide a straight code example.  However, the Bouncy Castle libraries are also &lt;a href=&quot;http://www.bouncycastle.org/csharp/&quot; rel=&quot;nofollow&quot;&gt;available in C#&lt;/a&gt;, so the same basic procedure outlined here should work in C# using the available BC libraries for .NET.</description>
		<content:encoded><![CDATA[<p>@hemant<br />
Unfortunately, I don&#8217;t really have any practical C# experience so I wouldn&#8217;t be able to provide a straight code example.  However, the Bouncy Castle libraries are also <a href="http://www.bouncycastle.org/csharp/" rel="nofollow">available in C#</a>, so the same basic procedure outlined here should work in C# using the available BC libraries for .NET.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hemant</title>
		<link>http://unitstep.net/blog/2008/10/27/extracting-x509-extensions-from-a-csr-using-the-bouncy-castle-apis/comment-page-1/#comment-156648</link>
		<dc:creator>hemant</dc:creator>
		<pubDate>Thu, 16 Apr 2009 20:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://unitstep.net/?p=407#comment-156648</guid>
		<description>Hello do you have any C# sample for decoding CSR?

Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hello do you have any C# sample for decoding CSR?</p>
<p>Thanks a lot.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

