{"action":"created","issue":{"url":"https://api.github.com/repos/chef-cookbooks/windows/issues/481","repository_url":"https://api.github.com/repos/chef-cookbooks/windows","labels_url":"https://api.github.com/repos/chef-cookbooks/windows/issues/481/labels{/name}","comments_url":"https://api.github.com/repos/chef-cookbooks/windows/issues/481/comments","events_url":"https://api.github.com/repos/chef-cookbooks/windows/issues/481/events","html_url":"https://github.com/chef-cookbooks/windows/issues/481","id":240206898,"number":481,"title":"Unable to set private key permissions - private key null","user":{"login":"taliesins","id":314567,"avatar_url":"https://avatars3.githubusercontent.com/u/314567?v=4","gravatar_id":"","url":"https://api.github.com/users/taliesins","html_url":"https://github.com/taliesins","followers_url":"https://api.github.com/users/taliesins/followers","following_url":"https://api.github.com/users/taliesins/following{/other_user}","gists_url":"https://api.github.com/users/taliesins/gists{/gist_id}","starred_url":"https://api.github.com/users/taliesins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taliesins/subscriptions","organizations_url":"https://api.github.com/users/taliesins/orgs","repos_url":"https://api.github.com/users/taliesins/repos","events_url":"https://api.github.com/users/taliesins/events{/privacy}","received_events_url":"https://api.github.com/users/taliesins/received_events","type":"User","site_admin":false},"labels":[{"id":418399662,"url":"https://api.github.com/repos/chef-cookbooks/windows/labels/Status:%20Maintainer%20Review%20Needed","name":"Status: Maintainer Review Needed","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-07-03T15:33:37Z","updated_at":"2018-05-24T13:23:00Z","closed_at":null,"author_association":"NONE","body":"### Cookbook version\r\nLatest version\r\n\r\n### Chef-client version\r\nLatest version\r\n\r\n### Platform Details\r\nWindows Server 2012 R2 with latest patches applied. I have tried to install the latest WIM 5.1 and it did not help. \r\n\r\n### Scenario:\r\nTrying to set ACL permissions on certificate\r\n\r\n### Steps to Reproduce:\r\n```\r\nwindows_certificate 'certname' do\r\n  private_key_acl [\"#{node[\"kernel\"][\"cs_info\"][\"user_name\"]}\", 'Administrator', 'BUILTIN\\Administrators']\r\nend\r\n```\r\n\r\n### Expected Result:\r\nPrivate key permissions to be set for certificate. \r\n\r\n### Actual Result:\r\nWhen not setting certificate permissions and loading MMC, you can see that certificate does have a private key.\r\n\r\nThis does not occur with all certificates. Only when CSP is CNG.\r\n\r\nI think the error is related to the following (TL;DR; .net has problems getting private key when CSP is CNG):\r\nhttps://blogs.technet.microsoft.com/vishalagarwal/2010/03/30/verifying-the-private-key-property-for-a-certificate-in-the-store/\r\n\r\nAnd we might be able to fix it using the following:\r\nhttps://stackoverflow.com/questions/17185429/how-to-grant-permission-to-private-key-from-powershell/22146915#22146915\r\n\r\n\r\nException occurs with the following error message:\r\n\r\n```\r\n[2017-07-03T15:25:53+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows\r\n_certificate[wildcard.office.interxion.net] (role-servicebus::default line 75) h\r\nad an error: Mixlib::ShellOut::ShellCommandFailed: powershell_script[wildcard.of\r\nfice.interxion.net] (C:/chef/cache/cookbooks/windows/resources/certificate.rb li\r\nne 39) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to e\r\nxit with [0], but received '1'\r\n---- Begin output of \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\"\r\n -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -F\r\nile \"C:/Users/vagrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\"\r\n ----\r\nSTDOUT:\r\nSTDERR: C:\\Users\\vagrant\\AppData\\Local\\Temp\\1\\chef-script20170703-2168-1vd4wys.p\r\ns1 :\r\nno private key exists.\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep\r\n   tion\r\n    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio\r\n   n,chef-script20170703-2168-1vd4wys.ps1\r\n---- End output of \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -\r\nNoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -Fil\r\ne \"C:/Users/vagrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\" -\r\n---\r\nRan \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoLogo -NonInte\r\nractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File \"C:/Users/vag\r\nrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\" returned 1\r\n[2017-07-03T15:25:53+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows\r\n_certificate[wildcard.office.interxion.net] (role-servicebus::default line 75) h\r\nad an error: Mixlib::ShellOut::ShellCommandFailed: powershell_script[wildcard.of\r\nfice.interxion.net] (C:/chef/cache/cookbooks/windows/resources/certificate.rb li\r\nne 39) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to e\r\nxit with [0], but received '1'\r\n---- Begin output of \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\"\r\n -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -F\r\nile \"C:/Users/vagrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\"\r\n ----\r\nSTDOUT:\r\nSTDERR: C:\\Users\\vagrant\\AppData\\Local\\Temp\\1\\chef-script20170703-2168-1vd4wys.p\r\ns1 :\r\nno private key exists.\r\n    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep\r\n   tion\r\n    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio\r\n   n,chef-script20170703-2168-1vd4wys.ps1\r\n---- End output of \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -\r\nNoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -Fil\r\ne \"C:/Users/vagrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\" -\r\n---\r\nRan \"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoLogo -NonInte\r\nractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File \"C:/Users/vag\r\nrant/AppData/Local/Temp/1/chef-script20170703-2168-1vd4wys.ps1\" returned 1\r\n```"},"comment":{"url":"https://api.github.com/repos/chef-cookbooks/windows/issues/comments/391712768","html_url":"https://github.com/chef-cookbooks/windows/issues/481#issuecomment-391712768","issue_url":"https://api.github.com/repos/chef-cookbooks/windows/issues/481","id":391712768,"user":{"login":"ilovemysillybanana","id":9522399,"avatar_url":"https://avatars1.githubusercontent.com/u/9522399?v=4","gravatar_id":"","url":"https://api.github.com/users/ilovemysillybanana","html_url":"https://github.com/ilovemysillybanana","followers_url":"https://api.github.com/users/ilovemysillybanana/followers","following_url":"https://api.github.com/users/ilovemysillybanana/following{/other_user}","gists_url":"https://api.github.com/users/ilovemysillybanana/gists{/gist_id}","starred_url":"https://api.github.com/users/ilovemysillybanana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilovemysillybanana/subscriptions","organizations_url":"https://api.github.com/users/ilovemysillybanana/orgs","repos_url":"https://api.github.com/users/ilovemysillybanana/repos","events_url":"https://api.github.com/users/ilovemysillybanana/events{/privacy}","received_events_url":"https://api.github.com/users/ilovemysillybanana/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T13:23:00Z","updated_at":"2018-05-24T13:23:00Z","author_association":"NONE","body":"@sergeydeg I've actually just started working with powershell, but if I could adapt the solution to my own needs I'd be happy to do so and create a pull request after. I'm using windows 2k16 so that would be great.\r\n\r\n@taliesins I am new to developing on Windows, my version of windows is using .NET 4.7 shouldn't I be immune from this problem?"}}
{"actor":{"display_login":"ilovemysillybanana"}}