{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/37117233","id":37117233,"diff_hunk":"@@ -0,0 +1,400 @@\n+using System;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Security.Cryptography;\n+using System.Security.Cryptography.X509Certificates;\n+using System.Text;\n+using System.Threading;\n+\n+namespace Internal.Cryptography.Pal\n+{\n+    /// <summary>\n+    /// Provides an implementation of an X509Store which is backed by files in a directory.\n+    /// </summary>\n+    internal class DirectoryBasedStoreProvider : IStorePal\n+    {\n+        // {thumbprint}.1.pfx to {thumbprint}.9.pfx\n+        private const int MaxSaveAttempts = 9; \n+        private const string PfxExtension = \".pfx\";\n+        // *.pfx ({thumbprint}.pfx or {thumbprint}.{ordinal}.pfx)\n+        private const string PfxWildcard = \"*\" + PfxExtension;\n+        // .*.pfx ({thumbprint}.{ordinal}.pfx)\n+        private const string PfxOrdinalWildcard = \".\" + PfxWildcard;\n+\n+        private readonly string _storePath;\n+        private List<X509Certificate2> _certificates;\n+        private FileSystemWatcher _watcher;\n+\n+        private readonly bool _readOnly;\n+\n+#if DEBUG\n+        static DirectoryBasedStoreProvider()\n+        {\n+            Debug.Assert(\n+                0 == OpenFlags.ReadOnly,\n+                \"OpenFlags.ReadOnly is not zero, read-only detection will not work\");\n+        }\n+#endif\n+\n+        internal DirectoryBasedStoreProvider(string storeName, OpenFlags openFlags)\n+        {\n+            if (string.IsNullOrEmpty(storeName))\n+            {\n+                throw new CryptographicException(SR.Arg_EmptyOrNullString);\n+            }\n+\n+            string directoryName = GetDirectoryName(storeName);\n+         \n+            _storePath = Path.Combine(\n+                Environment.GetEnvironmentVariable(\"HOME\"),","path":"src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/DirectoryBasedStoreProvider.cs","position":50,"original_position":50,"commit_id":"ecf51afbadf0b16256047c2acb200ef03216751c","original_commit_id":"ecf51afbadf0b16256047c2acb200ef03216751c","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"body":"Okay, with the delta commit that's about to appear, if I blank $HOME in a shell script before launching the tests I get:\r\n```\r\n   System.Security.Cryptography.X509Certificates.Tests.X509StoreTests.ReadMyCertificates [FAIL]\r\n      System.InvalidOperationException : The home directory of the current user could not be determined.\r\n      Stack Trace:\r\n            at System.IO.PersistedFiles.EnsureUserDirectories()\r\n            at System.IO.PersistedFiles.GetUserFeatureDirectory(String featureName, String subFeatureName)\r\n            at Internal.Cryptography.Pal.DirectoryBasedStoreProvider..ctor(String storeName, OpenFlags openFlags)\r\n            at Internal.Cryptography.Pal.StorePal.FromSystemStore(String storeName, StoreLocation storeLocation, OpenFlags openFlags)\r\n            at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)\r\n            at System.Security.Cryptography.X509Certificates.Tests.X509StoreTests.ReadMyCertificates()\r\n```","created_at":"2015-08-14T20:41:42Z","updated_at":"2015-08-14T20:41:42Z","html_url":"https://github.com/dotnet/corefx/pull/2806#discussion_r37117233","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/2806","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/37117233"},"html":{"href":"https://github.com/dotnet/corefx/pull/2806#discussion_r37117233"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2806"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/2806","id":42456105,"html_url":"https://github.com/dotnet/corefx/pull/2806","diff_url":"https://github.com/dotnet/corefx/pull/2806.diff","patch_url":"https://github.com/dotnet/corefx/pull/2806.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/2806","number":2806,"state":"open","locked":false,"title":"Enable CurrentUser X509Stores on Unix.","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"body":"The store is implemented as PFX files in ~/.microsoft/netfx/cryptography/x509stores/{storename}, and utilizes a FileSystemWatcher after first read to synchronize changes across other instances (and processes).\r\n\r\nFixes #2206.","created_at":"2015-08-14T13:35:27Z","updated_at":"2015-08-14T20:41:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"237029e84cb463f6794ed55650923b93630159ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/2806/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/2806/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/2806/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/ecf51afbadf0b16256047c2acb200ef03216751c","head":{"label":"bartonjs:X509Store_Unix_CurrentUser","ref":"X509Store_Unix_CurrentUser","sha":"ecf51afbadf0b16256047c2acb200ef03216751c","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"repo":{"id":29888389,"name":"corefx","full_name":"bartonjs/corefx","owner":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bartonjs/corefx","description":"This repository contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/bartonjs/corefx","forks_url":"https://api.github.com/repos/bartonjs/corefx/forks","keys_url":"https://api.github.com/repos/bartonjs/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bartonjs/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bartonjs/corefx/teams","hooks_url":"https://api.github.com/repos/bartonjs/corefx/hooks","issue_events_url":"https://api.github.com/repos/bartonjs/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/bartonjs/corefx/events","assignees_url":"https://api.github.com/repos/bartonjs/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/bartonjs/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/bartonjs/corefx/tags","blobs_url":"https://api.github.com/repos/bartonjs/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bartonjs/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bartonjs/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/bartonjs/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bartonjs/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/bartonjs/corefx/languages","stargazers_url":"https://api.github.com/repos/bartonjs/corefx/stargazers","contributors_url":"https://api.github.com/repos/bartonjs/corefx/contributors","subscribers_url":"https://api.github.com/repos/bartonjs/corefx/subscribers","subscription_url":"https://api.github.com/repos/bartonjs/corefx/subscription","commits_url":"https://api.github.com/repos/bartonjs/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/bartonjs/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/bartonjs/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/bartonjs/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/bartonjs/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/bartonjs/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bartonjs/corefx/merges","archive_url":"https://api.github.com/repos/bartonjs/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bartonjs/corefx/downloads","issues_url":"https://api.github.com/repos/bartonjs/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/bartonjs/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/bartonjs/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/bartonjs/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bartonjs/corefx/labels{/name}","releases_url":"https://api.github.com/repos/bartonjs/corefx/releases{/id}","created_at":"2015-01-26T23:55:53Z","updated_at":"2015-05-07T15:20:31Z","pushed_at":"2015-08-14T13:32:13Z","git_url":"git://github.com/bartonjs/corefx.git","ssh_url":"git@github.com:bartonjs/corefx.git","clone_url":"https://github.com/bartonjs/corefx.git","svn_url":"https://github.com/bartonjs/corefx","homepage":"","size":28009,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"cda0ae17da76af6bd726c5cbd9c3c55fa4b881de","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-08-14T13:56:04Z","pushed_at":"2015-08-14T19:34:21Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/core/","size":61965,"stargazers_count":8203,"watchers_count":8203,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1732,"mirror_url":null,"open_issues_count":555,"forks":1732,"open_issues":555,"watchers":8203,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2806"},"html":{"href":"https://github.com/dotnet/corefx/pull/2806"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2806"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/2806/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2806/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/2806/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/ecf51afbadf0b16256047c2acb200ef03216751c"}}}}