{"action":"created","comment":{"url":"https://api.github.com/repos/docker/notary/pulls/comments/46729318","id":46729318,"diff_hunk":"@@ -105,7 +106,9 @@ func (r *NotaryRepository) Initialize(rootKeyID string) error {\n \t\treturn err\n \t}\n \n-\trootCert, err := cryptoservice.GenerateCertificate(privKey, r.gun)\n+\t// Hard-coded policy: the generated certificate expires in 10 years.\n+\tstartTime := time.Now()\n+\trootCert, err := cryptoservice.GenerateCertificate(privKey, r.gun, startTime, startTime.AddDate(10, 0, 0))","path":"client/client.go","position":15,"original_position":15,"commit_id":"907cc0b1bb680f4c454b2bb27dcdb88bc687b177","original_commit_id":"907cc0b1bb680f4c454b2bb27dcdb88bc687b177","user":{"login":"mtrmac","id":7052838,"avatar_url":"https://avatars.githubusercontent.com/u/7052838?v=3","gravatar_id":"","url":"https://api.github.com/users/mtrmac","html_url":"https://github.com/mtrmac","followers_url":"https://api.github.com/users/mtrmac/followers","following_url":"https://api.github.com/users/mtrmac/following{/other_user}","gists_url":"https://api.github.com/users/mtrmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mtrmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtrmac/subscriptions","organizations_url":"https://api.github.com/users/mtrmac/orgs","repos_url":"https://api.github.com/users/mtrmac/repos","events_url":"https://api.github.com/users/mtrmac/events{/privacy}","received_events_url":"https://api.github.com/users/mtrmac/received_events","type":"User","site_admin":false},"body":"The ambition of this PR is to make functions available for testing; making the hard-coded policy more visible is mostly a side effect. Making the policy configurable should IMHO go into a separate PR, if it needs to be configurable at all (I don’t currently see a really strong reason for it to be configurable, OTOH I haven’t been thinking about it much.)\r\n\r\n(Also, `Time.Add(hours)` does not account for leap years the way `Time.AddDate` does, see 856f9021c8f08e9e6c7c7d43b9cec64d531a3605 . That’s certainly not a showstopper but it does lead to non-intuitive and surprising results.)","created_at":"2015-12-04T20:36:55Z","updated_at":"2015-12-04T20:36:55Z","html_url":"https://github.com/docker/notary/pull/312#discussion_r46729318","pull_request_url":"https://api.github.com/repos/docker/notary/pulls/312","_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/comments/46729318"},"html":{"href":"https://github.com/docker/notary/pull/312#discussion_r46729318"},"pull_request":{"href":"https://api.github.com/repos/docker/notary/pulls/312"}}},"pull_request":{"url":"https://api.github.com/repos/docker/notary/pulls/312","id":51523070,"html_url":"https://github.com/docker/notary/pull/312","diff_url":"https://github.com/docker/notary/pull/312.diff","patch_url":"https://github.com/docker/notary/pull/312.patch","issue_url":"https://api.github.com/repos/docker/notary/issues/312","number":312,"state":"open","locked":false,"title":"Cert expiration","user":{"login":"mtrmac","id":7052838,"avatar_url":"https://avatars.githubusercontent.com/u/7052838?v=3","gravatar_id":"","url":"https://api.github.com/users/mtrmac","html_url":"https://github.com/mtrmac","followers_url":"https://api.github.com/users/mtrmac/followers","following_url":"https://api.github.com/users/mtrmac/following{/other_user}","gists_url":"https://api.github.com/users/mtrmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mtrmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtrmac/subscriptions","organizations_url":"https://api.github.com/users/mtrmac/orgs","repos_url":"https://api.github.com/users/mtrmac/repos","events_url":"https://api.github.com/users/mtrmac/events{/privacy}","received_events_url":"https://api.github.com/users/mtrmac/received_events","type":"User","site_admin":false},"body":"This is a small subset of #267 , but mergeable and useful stand-alone:\r\n\r\nAdd an explicit `time.Time` parameter to `cryptoservice.GenerateCertificate` and `trustmanager.NewCertificate`.  This will allow writing tests of certificate expiry by generating appropriate certificates.\r\n\r\nThen, tighten `TestNewCertificate` to use equality comparisons and fix a revealed bug in `trustmanager.NewCertificate`, which was claiming to expire certificates in 10 years but did not account for leap days in the calculation.","created_at":"2015-11-23T13:31:39Z","updated_at":"2015-12-04T20:36:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6867e1165b96b8133cc37b01ab3b36643ee62c8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/notary/pulls/312/commits","review_comments_url":"https://api.github.com/repos/docker/notary/pulls/312/comments","review_comment_url":"https://api.github.com/repos/docker/notary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/notary/issues/312/comments","statuses_url":"https://api.github.com/repos/docker/notary/statuses/907cc0b1bb680f4c454b2bb27dcdb88bc687b177","head":{"label":"mtrmac:cert-expiration","ref":"cert-expiration","sha":"907cc0b1bb680f4c454b2bb27dcdb88bc687b177","user":{"login":"mtrmac","id":7052838,"avatar_url":"https://avatars.githubusercontent.com/u/7052838?v=3","gravatar_id":"","url":"https://api.github.com/users/mtrmac","html_url":"https://github.com/mtrmac","followers_url":"https://api.github.com/users/mtrmac/followers","following_url":"https://api.github.com/users/mtrmac/following{/other_user}","gists_url":"https://api.github.com/users/mtrmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mtrmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtrmac/subscriptions","organizations_url":"https://api.github.com/users/mtrmac/orgs","repos_url":"https://api.github.com/users/mtrmac/repos","events_url":"https://api.github.com/users/mtrmac/events{/privacy}","received_events_url":"https://api.github.com/users/mtrmac/received_events","type":"User","site_admin":false},"repo":{"id":44179162,"name":"notary","full_name":"mtrmac/notary","owner":{"login":"mtrmac","id":7052838,"avatar_url":"https://avatars.githubusercontent.com/u/7052838?v=3","gravatar_id":"","url":"https://api.github.com/users/mtrmac","html_url":"https://github.com/mtrmac","followers_url":"https://api.github.com/users/mtrmac/followers","following_url":"https://api.github.com/users/mtrmac/following{/other_user}","gists_url":"https://api.github.com/users/mtrmac/gists{/gist_id}","starred_url":"https://api.github.com/users/mtrmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtrmac/subscriptions","organizations_url":"https://api.github.com/users/mtrmac/orgs","repos_url":"https://api.github.com/users/mtrmac/repos","events_url":"https://api.github.com/users/mtrmac/events{/privacy}","received_events_url":"https://api.github.com/users/mtrmac/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mtrmac/notary","description":"","fork":true,"url":"https://api.github.com/repos/mtrmac/notary","forks_url":"https://api.github.com/repos/mtrmac/notary/forks","keys_url":"https://api.github.com/repos/mtrmac/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mtrmac/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mtrmac/notary/teams","hooks_url":"https://api.github.com/repos/mtrmac/notary/hooks","issue_events_url":"https://api.github.com/repos/mtrmac/notary/issues/events{/number}","events_url":"https://api.github.com/repos/mtrmac/notary/events","assignees_url":"https://api.github.com/repos/mtrmac/notary/assignees{/user}","branches_url":"https://api.github.com/repos/mtrmac/notary/branches{/branch}","tags_url":"https://api.github.com/repos/mtrmac/notary/tags","blobs_url":"https://api.github.com/repos/mtrmac/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mtrmac/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mtrmac/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/mtrmac/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mtrmac/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/mtrmac/notary/languages","stargazers_url":"https://api.github.com/repos/mtrmac/notary/stargazers","contributors_url":"https://api.github.com/repos/mtrmac/notary/contributors","subscribers_url":"https://api.github.com/repos/mtrmac/notary/subscribers","subscription_url":"https://api.github.com/repos/mtrmac/notary/subscription","commits_url":"https://api.github.com/repos/mtrmac/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/mtrmac/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/mtrmac/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/mtrmac/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/mtrmac/notary/contents/{+path}","compare_url":"https://api.github.com/repos/mtrmac/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mtrmac/notary/merges","archive_url":"https://api.github.com/repos/mtrmac/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mtrmac/notary/downloads","issues_url":"https://api.github.com/repos/mtrmac/notary/issues{/number}","pulls_url":"https://api.github.com/repos/mtrmac/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/mtrmac/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/mtrmac/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mtrmac/notary/labels{/name}","releases_url":"https://api.github.com/repos/mtrmac/notary/releases{/id}","created_at":"2015-10-13T13:45:35Z","updated_at":"2015-10-13T13:45:38Z","pushed_at":"2015-12-02T17:41:06Z","git_url":"git://github.com/mtrmac/notary.git","ssh_url":"git@github.com:mtrmac/notary.git","clone_url":"https://github.com/mtrmac/notary.git","svn_url":"https://github.com/mtrmac/notary","homepage":null,"size":21696,"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":"docker:master","ref":"master","sha":"8292d1866d8b7c2825fac653769568aa6ce2ab36","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":37743436,"name":"notary","full_name":"docker/notary","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/notary","description":"","fork":false,"url":"https://api.github.com/repos/docker/notary","forks_url":"https://api.github.com/repos/docker/notary/forks","keys_url":"https://api.github.com/repos/docker/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/notary/teams","hooks_url":"https://api.github.com/repos/docker/notary/hooks","issue_events_url":"https://api.github.com/repos/docker/notary/issues/events{/number}","events_url":"https://api.github.com/repos/docker/notary/events","assignees_url":"https://api.github.com/repos/docker/notary/assignees{/user}","branches_url":"https://api.github.com/repos/docker/notary/branches{/branch}","tags_url":"https://api.github.com/repos/docker/notary/tags","blobs_url":"https://api.github.com/repos/docker/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/notary/languages","stargazers_url":"https://api.github.com/repos/docker/notary/stargazers","contributors_url":"https://api.github.com/repos/docker/notary/contributors","subscribers_url":"https://api.github.com/repos/docker/notary/subscribers","subscription_url":"https://api.github.com/repos/docker/notary/subscription","commits_url":"https://api.github.com/repos/docker/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/notary/contents/{+path}","compare_url":"https://api.github.com/repos/docker/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/notary/merges","archive_url":"https://api.github.com/repos/docker/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/notary/downloads","issues_url":"https://api.github.com/repos/docker/notary/issues{/number}","pulls_url":"https://api.github.com/repos/docker/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/notary/labels{/name}","releases_url":"https://api.github.com/repos/docker/notary/releases{/id}","created_at":"2015-06-19T20:07:53Z","updated_at":"2015-12-01T14:37:41Z","pushed_at":"2015-12-04T19:20:30Z","git_url":"git://github.com/docker/notary.git","ssh_url":"git@github.com:docker/notary.git","clone_url":"https://github.com/docker/notary.git","svn_url":"https://github.com/docker/notary","homepage":null,"size":21896,"stargazers_count":442,"watchers_count":442,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":61,"mirror_url":null,"open_issues_count":42,"forks":61,"open_issues":42,"watchers":442,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/312"},"html":{"href":"https://github.com/docker/notary/pull/312"},"issue":{"href":"https://api.github.com/repos/docker/notary/issues/312"},"comments":{"href":"https://api.github.com/repos/docker/notary/issues/312/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/notary/pulls/312/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/notary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/notary/pulls/312/commits"},"statuses":{"href":"https://api.github.com/repos/docker/notary/statuses/907cc0b1bb680f4c454b2bb27dcdb88bc687b177"}}}}