<?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>Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx</link><description>For a personal project involving SSL, I wanted to create some certificates that could be used to authenticate the client and server to each other. Nothing fancy - self-signed is perfectly fine in this case since the client would have an actual copy of</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9370559</link><pubDate>Thu, 22 Jan 2009 23:37:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9370559</guid><dc:creator>mohit</dc:creator><description>&lt;p&gt;I have been through you code. Can you please give comment to what and why for the above bullet points and also when i created certificate using the given class i get following error:&lt;/p&gt;
&lt;p&gt;Certificate status&lt;/p&gt;
&lt;p&gt;This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store.&lt;/p&gt;
&lt;p&gt;But being a selfsigned certificate the status should be ok. The same way when we create a certificate with IIS.&lt;/p&gt;
&lt;p&gt;Please help&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;mohit&lt;/p&gt;
&lt;p&gt;mohit_raghav at hotmail dot com&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9371495</link><pubDate>Fri, 23 Jan 2009 02:30:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9371495</guid><dc:creator>jclary</dc:creator><description>&lt;p&gt;Great code and it works wonderfully but is there a way to set the key length?&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9371540</link><pubDate>Fri, 23 Jan 2009 02:38:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9371540</guid><dc:creator>jclary</dc:creator><description>&lt;p&gt;Being able to set the FriendlyName would be useful, too. &lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9404119</link><pubDate>Sat, 07 Feb 2009 12:10:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9404119</guid><dc:creator>jclary</dc:creator><description>&lt;p&gt;I found a solution to setting the key length. &amp;nbsp;The third parameter to CryptKeyGen(), flags, needs to be bitwise OR'd (|) with 2048&amp;lt;&amp;lt;16 (0x080000000) to get a 2048bit key -- you end up passing in 0x08000001.&lt;/p&gt;
&lt;p&gt;Check(NativeMethods.CryptGenKey(&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;providerContext,&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;1, // AT_KEYEXCHANGE&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;1 | (2048&amp;lt;&amp;lt;16), // CRYPT_EXPORTABLE | 2048bit&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;out cryptKey));&lt;/p&gt;
&lt;p&gt;I still haven't found a way to add the FriendlyName parameter.&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9419488</link><pubDate>Fri, 13 Feb 2009 20:49:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9419488</guid><dc:creator>sszelei</dc:creator><description>&lt;p&gt;How Timely, &amp;nbsp;I was looking for this several weeks ago and had all but given up and started writing my own with much hardship. &amp;nbsp;Just happened to run accross this when looking up function calls. &amp;nbsp;This was great! Thank you! Thank You! Thank You! Tou saved me some gray hairs.&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9545953</link><pubDate>Sun, 12 Apr 2009 02:42:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9545953</guid><dc:creator>kevindelafield</dc:creator><description>&lt;p&gt;Did you get this to work?&lt;/p&gt;
&lt;p&gt;When I use this routine to create a certficiate and try to store it in the cert store for My/CurrentUser, &lt;/p&gt;
&lt;p&gt;and then extract the filename with 'FindPrivateKey' (from WCF examples), I get an error that the private key file is missing.&lt;/p&gt;
&lt;p&gt;Are you sure this generates a private key?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kevin&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9545956</link><pubDate>Sun, 12 Apr 2009 02:51:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9545956</guid><dc:creator>kevindelafield</dc:creator><description>&lt;p&gt;Also,&lt;/p&gt;
&lt;p&gt;When I use the Certificates MMC plugin to view the certificate,&lt;/p&gt;
&lt;p&gt;and I double click it, it says that there is a private key.&lt;/p&gt;
&lt;p&gt;However, when I try to export it, it says the associated private key cannot be found.&lt;/p&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Kevin&lt;/p&gt;
</description></item><item><title>re: Creating a self-signed certificate in C#</title><link>http://blogs.msdn.com/dcook/archive/2008/11/25/creating-a-self-signed-certificate-in-c.aspx#9840868</link><pubDate>Mon, 20 Jul 2009 08:05:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9840868</guid><dc:creator>Jeremy Holovacs</dc:creator><description>&lt;p&gt;For the FriendlyName and Description (and other useful information) it looks like these are extended properties added with CertSetCertificateContextProperty (CERT_DESCRIPTION_PROP_ID = 13, CERT_FRIENDLY_NAME_PROP_ID = 11) etc... I haven't figured out how to create the pointer context for the CRYPT_DATA_BLOB structure (trying to convert this in my head to VB.NET and this is well outside my comfort zone) but I think this'll work.&lt;/p&gt;
</description></item></channel></rss>