{"id":400,"date":"2017-02-17T17:11:01","date_gmt":"2017-02-17T17:11:01","guid":{"rendered":"http:\/\/www.mattjm.com\/wordpress\/?p=400"},"modified":"2019-05-28T09:07:41","modified_gmt":"2019-05-28T17:07:41","slug":"windows-certificate-store-permissions","status":"publish","type":"post","link":"https:\/\/www.mattjm.com\/blog\/2017\/02\/17\/windows-certificate-store-permissions\/","title":{"rendered":"Windows Certificate Store Permissions"},"content":{"rendered":"<p>The Windows certificate store, especially private key permissions, has caused no end of misery for people the world over. I recently discovered something that seems to get around private key permission nonsense. I&#8217;m not sure why, but it works. Note this only works with .NET Framework 4.6 or later.<\/p>\n<p>Suppose you already have an X509Certificate object called &#8220;cert&#8221;. Running this code once you have the object seems to magically make permission issues on the private key disappear (note you need &#8220;using System.Security.Cryptography;&#8221;):<\/p>\n<p><code><br \/>\nX509Certificate2 samecert = (X509Certificate2)cert;<br \/>\nRSA rsaobj = samecert.GetRSAPrivateKey();<br \/>\n((IDisposable)rsaobj).Dispose();<br \/>\n<\/code><\/p>\n<p>If you&#8217;ve dug enough into the code or documentation enough to understand what&#8217;s going on here, please comment. I have a few ideas but nothing I could write coherently about right now. I sort of suspect this was always the way it was supposed to work&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Windows certificate store, especially private key permissions, has caused no end of misery for people the world over. I recently discovered something that seems to get around private key permission nonsense. I&#8217;m not sure why, but it works. Note this only works with .NET Framework 4.6 or later. Suppose you already have an X509Certificate &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.mattjm.com\/blog\/2017\/02\/17\/windows-certificate-store-permissions\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Windows Certificate Store Permissions&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/posts\/400"}],"collection":[{"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/comments?post=400"}],"version-history":[{"count":1,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":404,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/posts\/400\/revisions\/404"}],"wp:attachment":[{"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/media?parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/categories?post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mattjm.com\/blog\/wp-json\/wp\/v2\/tags?post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}