
{"id":1975,"date":"2016-02-24T09:48:44","date_gmt":"2016-02-24T14:48:44","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=1975"},"modified":"2016-02-24T09:48:44","modified_gmt":"2016-02-24T14:48:44","slug":"access-denied-when-creating-a-certificate-enrollment-request","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=1975","title":{"rendered":"Access denied when creating a certificate enrollment request"},"content":{"rendered":"<p>As part of creating self-signed certificate, we use the following code:<\/p>\n<pre>\nvar enroll = new CX509Enrollment();\nenroll.InitializeFromRequest(cert);\nenroll.CertificateFriendlyName = friendlyName;\nstring csr = <b><font color=\"red\">enroll.CreateRequest()<\/font><\/b>; <font color=\"green\">\/\/ may fail with ACCESS DENIED<\/font>\n<\/pre>\n<p>The latter is a call to COM method <code>IX509Enrollment::CreateRequest()<\/code>. If you are not running with elevated privileges, it will return with &#8220;access denied&#8221;, because it wants write access to <code>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SystemCertificates<\/code>. Note, that in latest versions of Windows most programs run without elevated privileges, even if current user has administrator rights. The program executing the above code must be specifically started via  &#8220;run as administrator&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of creating self-signed certificate, we use the following code: var enroll = new CX509Enrollment(); enroll.InitializeFromRequest(cert); enroll.CertificateFriendlyName = friendlyName; string csr = enroll.CreateRequest(); \/\/ may fail with ACCESS DENIED <a href=\"https:\/\/ikriv.com\/blog\/?p=1975\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4],"tags":[],"class_list":["entry","author-ikriv","post-1975","post","type-post","status-publish","format-standard","category-hack"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1975"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1975\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}