{"action":"created","comment":{"url":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/72031295","id":72031295,"diff_hunk":"@@ -123,69 +213,141 @@ func getIssuer(cert *x509.Certificate) *x509.Certificate {\n \t}\n \n \treturn issuer\n-\n }\n \n-// check a cert against a specific CRL. Returns the same bool pair\n-// as revCheck.\n-func certIsRevokedCRL(cert *x509.Certificate, url string) (revoked, ok bool) {\n-\tcrl, ok := CRLSet[url]\n+// checks whether CRL in memory is valid\n+func (r *Revoke) isInMemoryCRLValid(key string) bool {\n+\tdefer r.lock.Unlock()\n+\tr.lock.Lock()\n+\tcrl, ok := r.crlSet[key]\n \tif ok && crl == nil {\n \t\tok = false\n-\t\tdelete(CRLSet, url)\n+\t\tdelete(r.crlSet, key)\n \t}\n \n-\tvar shouldFetchCRL = true\n-\tif ok {\n-\t\tif !crl.HasExpired(time.Now()) {\n-\t\t\tshouldFetchCRL = false\n+\tif ok && !crl.HasExpired(time.Now()) {\n+\t\treturn true\n+\t}\n+\n+\treturn false\n+}\n+\n+// fetchLocalCRL reads CRL from the local filesystem\n+// force flag allows you to update the CRL\n+func (r *Revoke) fetchLocalCRL(newLocalCRL string, force bool) error {\n+\tif force || !r.isInMemoryCRLValid(newLocalCRL) {\n+\t\tif _, err := os.Stat(newLocalCRL); err != nil {\n+\t\t\treturn fmt.Errorf(\"failed to read local CRL path: %v\", err)\n+\t\t}\n+\n+\t\ttmp, err := ioutil.ReadFile(newLocalCRL)\n+\t\tif err != nil {\n+\t\t\treturn fmt.Errorf(\"failed to read local CRL path: %v\", err)\n+\t\t}\n+\t\tcrl, err := x509.ParseCRL(tmp)\n+\t\tif err != nil {\n+\t\t\treturn fmt.Errorf(\"failed to parse local CRL file: %v\", err)\n \t\t}\n+\n+\t\tr.lock.Lock()\n+\t\tr.crlSet[newLocalCRL] = crl\n+\t\tif r.localCRL != newLocalCRL {\n+\t\t\tif _, ok := r.crlSet[r.localCRL]; ok {\n+\t\t\t\tdelete(r.crlSet, r.localCRL)\n+\t\t\t}\n+\t\t\tr.localCRL = newLocalCRL\n+\t\t}\n+\t\tr.lock.Unlock()\n \t}\n \n+\treturn nil\n+}\n+\n+// FetchRemoteCRL fetches remote CRL into internal map,\n+// force overwrites previously read CRL\n+func (r *Revoke) FetchRemoteCRL(url string, cert *x509.Certificate, force bool) error {","path":"revoke/revoke.go","position":239,"original_position":239,"commit_id":"5063ba9defaffa5a543355162e7802ca2d0907c5","original_commit_id":"5063ba9defaffa5a543355162e7802ca2d0907c5","user":{"login":"kayrus","id":4047483,"avatar_url":"https://avatars.githubusercontent.com/u/4047483?v=3","gravatar_id":"","url":"https://api.github.com/users/kayrus","html_url":"https://github.com/kayrus","followers_url":"https://api.github.com/users/kayrus/followers","following_url":"https://api.github.com/users/kayrus/following{/other_user}","gists_url":"https://api.github.com/users/kayrus/gists{/gist_id}","starred_url":"https://api.github.com/users/kayrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayrus/subscriptions","organizations_url":"https://api.github.com/users/kayrus/orgs","repos_url":"https://api.github.com/users/kayrus/repos","events_url":"https://api.github.com/users/kayrus/events{/privacy}","received_events_url":"https://api.github.com/users/kayrus/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2016-07-25T09:10:19Z","updated_at":"2016-07-25T09:10:19Z","html_url":"https://github.com/cloudflare/cfssl/pull/637#discussion_r72031295","pull_request_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/637","_links":{"self":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/72031295"},"html":{"href":"https://github.com/cloudflare/cfssl/pull/637#discussion_r72031295"},"pull_request":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/637"}}},"pull_request":{"url":"https://api.github.com/repos/cloudflare/cfssl/pulls/637","id":77810368,"html_url":"https://github.com/cloudflare/cfssl/pull/637","diff_url":"https://github.com/cloudflare/cfssl/pull/637.diff","patch_url":"https://github.com/cloudflare/cfssl/pull/637.patch","issue_url":"https://api.github.com/repos/cloudflare/cfssl/issues/637","number":637,"state":"open","locked":false,"title":"revoke: implement thread-safe compatibility and local file CRL","user":{"login":"kayrus","id":4047483,"avatar_url":"https://avatars.githubusercontent.com/u/4047483?v=3","gravatar_id":"","url":"https://api.github.com/users/kayrus","html_url":"https://github.com/kayrus","followers_url":"https://api.github.com/users/kayrus/followers","following_url":"https://api.github.com/users/kayrus/following{/other_user}","gists_url":"https://api.github.com/users/kayrus/gists{/gist_id}","starred_url":"https://api.github.com/users/kayrus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kayrus/subscriptions","organizations_url":"https://api.github.com/users/kayrus/orgs","repos_url":"https://api.github.com/users/kayrus/repos","events_url":"https://api.github.com/users/kayrus/events{/privacy}","received_events_url":"https://api.github.com/users/kayrus/received_events","type":"User","site_admin":false},"body":"subj","created_at":"2016-07-18T13:45:47Z","updated_at":"2016-07-25T09:10:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbc770ac6f3d6ac7c067e56bdeb12a6c645aeb22","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/637/commits","review_comments_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/637/comments","review_comment_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudflare/cfssl/issues/637/comments","statuses_url":"https://api.github.com/repos/cloudflare/cfssl/statuses/5063ba9defaffa5a543355162e7802ca2d0907c5","head":{"label":"endocode:kayrus/local_crl","ref":"kayrus/local_crl","sha":"5063ba9defaffa5a543355162e7802ca2d0907c5","user":{"login":"endocode","id":4068543,"avatar_url":"https://avatars.githubusercontent.com/u/4068543?v=3","gravatar_id":"","url":"https://api.github.com/users/endocode","html_url":"https://github.com/endocode","followers_url":"https://api.github.com/users/endocode/followers","following_url":"https://api.github.com/users/endocode/following{/other_user}","gists_url":"https://api.github.com/users/endocode/gists{/gist_id}","starred_url":"https://api.github.com/users/endocode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endocode/subscriptions","organizations_url":"https://api.github.com/users/endocode/orgs","repos_url":"https://api.github.com/users/endocode/repos","events_url":"https://api.github.com/users/endocode/events{/privacy}","received_events_url":"https://api.github.com/users/endocode/received_events","type":"Organization","site_admin":false},"repo":{"id":42570553,"name":"cfssl","full_name":"endocode/cfssl","owner":{"login":"endocode","id":4068543,"avatar_url":"https://avatars.githubusercontent.com/u/4068543?v=3","gravatar_id":"","url":"https://api.github.com/users/endocode","html_url":"https://github.com/endocode","followers_url":"https://api.github.com/users/endocode/followers","following_url":"https://api.github.com/users/endocode/following{/other_user}","gists_url":"https://api.github.com/users/endocode/gists{/gist_id}","starred_url":"https://api.github.com/users/endocode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endocode/subscriptions","organizations_url":"https://api.github.com/users/endocode/orgs","repos_url":"https://api.github.com/users/endocode/repos","events_url":"https://api.github.com/users/endocode/events{/privacy}","received_events_url":"https://api.github.com/users/endocode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/endocode/cfssl","description":"CFSSL: CloudFlare's PKI toolkit","fork":true,"url":"https://api.github.com/repos/endocode/cfssl","forks_url":"https://api.github.com/repos/endocode/cfssl/forks","keys_url":"https://api.github.com/repos/endocode/cfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/endocode/cfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/endocode/cfssl/teams","hooks_url":"https://api.github.com/repos/endocode/cfssl/hooks","issue_events_url":"https://api.github.com/repos/endocode/cfssl/issues/events{/number}","events_url":"https://api.github.com/repos/endocode/cfssl/events","assignees_url":"https://api.github.com/repos/endocode/cfssl/assignees{/user}","branches_url":"https://api.github.com/repos/endocode/cfssl/branches{/branch}","tags_url":"https://api.github.com/repos/endocode/cfssl/tags","blobs_url":"https://api.github.com/repos/endocode/cfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/endocode/cfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/endocode/cfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/endocode/cfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/endocode/cfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/endocode/cfssl/languages","stargazers_url":"https://api.github.com/repos/endocode/cfssl/stargazers","contributors_url":"https://api.github.com/repos/endocode/cfssl/contributors","subscribers_url":"https://api.github.com/repos/endocode/cfssl/subscribers","subscription_url":"https://api.github.com/repos/endocode/cfssl/subscription","commits_url":"https://api.github.com/repos/endocode/cfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/endocode/cfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/endocode/cfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/endocode/cfssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/endocode/cfssl/contents/{+path}","compare_url":"https://api.github.com/repos/endocode/cfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/endocode/cfssl/merges","archive_url":"https://api.github.com/repos/endocode/cfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/endocode/cfssl/downloads","issues_url":"https://api.github.com/repos/endocode/cfssl/issues{/number}","pulls_url":"https://api.github.com/repos/endocode/cfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/endocode/cfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/endocode/cfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/endocode/cfssl/labels{/name}","releases_url":"https://api.github.com/repos/endocode/cfssl/releases{/id}","deployments_url":"https://api.github.com/repos/endocode/cfssl/deployments","created_at":"2015-09-16T07:00:15Z","updated_at":"2016-07-18T11:01:42Z","pushed_at":"2016-07-23T07:23:58Z","git_url":"git://github.com/endocode/cfssl.git","ssh_url":"git@github.com:endocode/cfssl.git","clone_url":"https://github.com/endocode/cfssl.git","svn_url":"https://github.com/endocode/cfssl","homepage":"https://cfssl.org/","size":8728,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"cloudflare:master","ref":"master","sha":"4a47280f81d5234ae621bfff451a174af664c793","user":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"repo":{"id":21591001,"name":"cfssl","full_name":"cloudflare/cfssl","owner":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudflare/cfssl","description":"CFSSL: CloudFlare's PKI and TLS toolkit","fork":false,"url":"https://api.github.com/repos/cloudflare/cfssl","forks_url":"https://api.github.com/repos/cloudflare/cfssl/forks","keys_url":"https://api.github.com/repos/cloudflare/cfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudflare/cfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudflare/cfssl/teams","hooks_url":"https://api.github.com/repos/cloudflare/cfssl/hooks","issue_events_url":"https://api.github.com/repos/cloudflare/cfssl/issues/events{/number}","events_url":"https://api.github.com/repos/cloudflare/cfssl/events","assignees_url":"https://api.github.com/repos/cloudflare/cfssl/assignees{/user}","branches_url":"https://api.github.com/repos/cloudflare/cfssl/branches{/branch}","tags_url":"https://api.github.com/repos/cloudflare/cfssl/tags","blobs_url":"https://api.github.com/repos/cloudflare/cfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudflare/cfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudflare/cfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudflare/cfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudflare/cfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudflare/cfssl/languages","stargazers_url":"https://api.github.com/repos/cloudflare/cfssl/stargazers","contributors_url":"https://api.github.com/repos/cloudflare/cfssl/contributors","subscribers_url":"https://api.github.com/repos/cloudflare/cfssl/subscribers","subscription_url":"https://api.github.com/repos/cloudflare/cfssl/subscription","commits_url":"https://api.github.com/repos/cloudflare/cfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudflare/cfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudflare/cfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudflare/cfssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudflare/cfssl/contents/{+path}","compare_url":"https://api.github.com/repos/cloudflare/cfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudflare/cfssl/merges","archive_url":"https://api.github.com/repos/cloudflare/cfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudflare/cfssl/downloads","issues_url":"https://api.github.com/repos/cloudflare/cfssl/issues{/number}","pulls_url":"https://api.github.com/repos/cloudflare/cfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudflare/cfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudflare/cfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudflare/cfssl/labels{/name}","releases_url":"https://api.github.com/repos/cloudflare/cfssl/releases{/id}","deployments_url":"https://api.github.com/repos/cloudflare/cfssl/deployments","created_at":"2014-07-07T23:49:12Z","updated_at":"2016-07-25T03:39:08Z","pushed_at":"2016-07-23T07:23:59Z","git_url":"git://github.com/cloudflare/cfssl.git","ssh_url":"git@github.com:cloudflare/cfssl.git","clone_url":"https://github.com/cloudflare/cfssl.git","svn_url":"https://github.com/cloudflare/cfssl","homepage":"https://cfssl.org/","size":11587,"stargazers_count":1427,"watchers_count":1427,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":195,"mirror_url":null,"open_issues_count":65,"forks":195,"open_issues":65,"watchers":1427,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/637"},"html":{"href":"https://github.com/cloudflare/cfssl/pull/637"},"issue":{"href":"https://api.github.com/repos/cloudflare/cfssl/issues/637"},"comments":{"href":"https://api.github.com/repos/cloudflare/cfssl/issues/637/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/637/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/637/commits"},"statuses":{"href":"https://api.github.com/repos/cloudflare/cfssl/statuses/5063ba9defaffa5a543355162e7802ca2d0907c5"}}}}
{"actor":{"display_login":"kayrus"}}