{"action":"created","comment":{"url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments/50947350","id":50947350,"diff_hunk":"@@ -46,3 +103,143 @@ impl Drop for Asn1Time {\n         }\n     }\n }\n+\n+/// Given a timespec, generate an ASN.1 string suitible for passing to openssl.\n+///\n+/// Note that this does lose the seconds offset from the timezone, but note that most (all?)\n+/// timezone's lack a seconds offset in any case.\n+pub fn tm_to_asn1_string(t: time::Tm) -> String\n+{\n+    let tz_hours = t.tm_utcoff / 60 / 60;\n+    let tz_min = (t.tm_utcoff).abs() / 60 % 60;\n+    /* Note that strftime is undesirable as it lacks support for nanoseconds */\n+    /* YYYYMMDDHHMMSS.nsZ */\n+    /*       YYYY MM   DD   HH   MM   SS   .ns   Z */\n+    format!(\"{:04}{:02}{:02}{:02}{:02}{:02}.{:09}{:+03}{:02}\",\n+            t.tm_year + 1900,\n+            t.tm_mon + 1,\n+            t.tm_mday,\n+            t.tm_hour,\n+            t.tm_min,\n+            t.tm_sec,\n+            t.tm_nsec,\n+            tz_hours,\n+            tz_min)\n+}\n+\n+fn parse_n_digit<I>(b: &mut I, ct: usize, name: &str) -> Result<i32, String>","path":"openssl/src/asn1/mod.rs","position":110,"original_position":110,"commit_id":"c2d84cc532fff64371a02b5c42df4849f5ab472d","original_commit_id":"c2d84cc532fff64371a02b5c42df4849f5ab472d","user":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars.githubusercontent.com/u/1455697?v=3","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"body":"Can't this be replaced with `i32`'s `FromStr` impl on `&str[..ct]`?","created_at":"2016-01-27T06:56:32Z","updated_at":"2016-01-27T06:56:32Z","html_url":"https://github.com/sfackler/rust-openssl/pull/341#discussion_r50947350","pull_request_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341","_links":{"self":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments/50947350"},"html":{"href":"https://github.com/sfackler/rust-openssl/pull/341#discussion_r50947350"},"pull_request":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341"}}},"pull_request":{"url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341","id":57230802,"html_url":"https://github.com/sfackler/rust-openssl/pull/341","diff_url":"https://github.com/sfackler/rust-openssl/pull/341.diff","patch_url":"https://github.com/sfackler/rust-openssl/pull/341.patch","issue_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/341","number":341,"state":"open","locked":false,"title":"x509: allow setting & getting validity times to use time::Tm and std::time::Duration","user":{"login":"jmesmon","id":103437,"avatar_url":"https://avatars.githubusercontent.com/u/103437?v=3","gravatar_id":"","url":"https://api.github.com/users/jmesmon","html_url":"https://github.com/jmesmon","followers_url":"https://api.github.com/users/jmesmon/followers","following_url":"https://api.github.com/users/jmesmon/following{/other_user}","gists_url":"https://api.github.com/users/jmesmon/gists{/gist_id}","starred_url":"https://api.github.com/users/jmesmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmesmon/subscriptions","organizations_url":"https://api.github.com/users/jmesmon/orgs","repos_url":"https://api.github.com/users/jmesmon/repos","events_url":"https://api.github.com/users/jmesmon/events{/privacy}","received_events_url":"https://api.github.com/users/jmesmon/received_events","type":"User","site_admin":false},"body":"To support this, `Asn1Time` grows the ability to be constructed from a `time::Tm` and converted to a `time::Tm`.\r\n\r\nAdditionally, a few extra methods were added to `X509Generator` and the way it tracks validity prior to cert signing was adjusted.\r\n\r\nFor the `Asn1Time` <=> `time::Tm` conversion, I had to add a parser for ASN.1 formatted times.\r\nI don't really like this, but the API the openssl exposes doesn't appear provide another way to do this (without precision & 32bit hazards via `time_t`).\r\n\r\nNote that I am mixing `time::Tm` and `std::time::Duration` here. Ideally I'd use all `std` data-structures, but there isn't anything comparable to `time::Tm` (yet, anyhow) so I've stuck with using `std` where possible but falling back to the `time` crate.\r\n\r\n","created_at":"2016-01-26T16:03:48Z","updated_at":"2016-01-27T06:56:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d33bd9b0c89269cd42ed8664d606047d64966829","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341/commits","review_comments_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341/comments","review_comment_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/341/comments","statuses_url":"https://api.github.com/repos/sfackler/rust-openssl/statuses/c2d84cc532fff64371a02b5c42df4849f5ab472d","head":{"label":"jmesmon:asn1time-generalize","ref":"asn1time-generalize","sha":"c2d84cc532fff64371a02b5c42df4849f5ab472d","user":{"login":"jmesmon","id":103437,"avatar_url":"https://avatars.githubusercontent.com/u/103437?v=3","gravatar_id":"","url":"https://api.github.com/users/jmesmon","html_url":"https://github.com/jmesmon","followers_url":"https://api.github.com/users/jmesmon/followers","following_url":"https://api.github.com/users/jmesmon/following{/other_user}","gists_url":"https://api.github.com/users/jmesmon/gists{/gist_id}","starred_url":"https://api.github.com/users/jmesmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmesmon/subscriptions","organizations_url":"https://api.github.com/users/jmesmon/orgs","repos_url":"https://api.github.com/users/jmesmon/repos","events_url":"https://api.github.com/users/jmesmon/events{/privacy}","received_events_url":"https://api.github.com/users/jmesmon/received_events","type":"User","site_admin":false},"repo":{"id":24380283,"name":"rust-openssl","full_name":"jmesmon/rust-openssl","owner":{"login":"jmesmon","id":103437,"avatar_url":"https://avatars.githubusercontent.com/u/103437?v=3","gravatar_id":"","url":"https://api.github.com/users/jmesmon","html_url":"https://github.com/jmesmon","followers_url":"https://api.github.com/users/jmesmon/followers","following_url":"https://api.github.com/users/jmesmon/following{/other_user}","gists_url":"https://api.github.com/users/jmesmon/gists{/gist_id}","starred_url":"https://api.github.com/users/jmesmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmesmon/subscriptions","organizations_url":"https://api.github.com/users/jmesmon/orgs","repos_url":"https://api.github.com/users/jmesmon/repos","events_url":"https://api.github.com/users/jmesmon/events{/privacy}","received_events_url":"https://api.github.com/users/jmesmon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jmesmon/rust-openssl","description":"OpenSSL bindings for Rust","fork":true,"url":"https://api.github.com/repos/jmesmon/rust-openssl","forks_url":"https://api.github.com/repos/jmesmon/rust-openssl/forks","keys_url":"https://api.github.com/repos/jmesmon/rust-openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jmesmon/rust-openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jmesmon/rust-openssl/teams","hooks_url":"https://api.github.com/repos/jmesmon/rust-openssl/hooks","issue_events_url":"https://api.github.com/repos/jmesmon/rust-openssl/issues/events{/number}","events_url":"https://api.github.com/repos/jmesmon/rust-openssl/events","assignees_url":"https://api.github.com/repos/jmesmon/rust-openssl/assignees{/user}","branches_url":"https://api.github.com/repos/jmesmon/rust-openssl/branches{/branch}","tags_url":"https://api.github.com/repos/jmesmon/rust-openssl/tags","blobs_url":"https://api.github.com/repos/jmesmon/rust-openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jmesmon/rust-openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jmesmon/rust-openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/jmesmon/rust-openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jmesmon/rust-openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/jmesmon/rust-openssl/languages","stargazers_url":"https://api.github.com/repos/jmesmon/rust-openssl/stargazers","contributors_url":"https://api.github.com/repos/jmesmon/rust-openssl/contributors","subscribers_url":"https://api.github.com/repos/jmesmon/rust-openssl/subscribers","subscription_url":"https://api.github.com/repos/jmesmon/rust-openssl/subscription","commits_url":"https://api.github.com/repos/jmesmon/rust-openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/jmesmon/rust-openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/jmesmon/rust-openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/jmesmon/rust-openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/jmesmon/rust-openssl/contents/{+path}","compare_url":"https://api.github.com/repos/jmesmon/rust-openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jmesmon/rust-openssl/merges","archive_url":"https://api.github.com/repos/jmesmon/rust-openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jmesmon/rust-openssl/downloads","issues_url":"https://api.github.com/repos/jmesmon/rust-openssl/issues{/number}","pulls_url":"https://api.github.com/repos/jmesmon/rust-openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/jmesmon/rust-openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/jmesmon/rust-openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jmesmon/rust-openssl/labels{/name}","releases_url":"https://api.github.com/repos/jmesmon/rust-openssl/releases{/id}","deployments_url":"https://api.github.com/repos/jmesmon/rust-openssl/deployments","created_at":"2014-09-23T16:44:56Z","updated_at":"2016-01-18T21:44:23Z","pushed_at":"2016-01-26T16:04:31Z","git_url":"git://github.com/jmesmon/rust-openssl.git","ssh_url":"git@github.com:jmesmon/rust-openssl.git","clone_url":"https://github.com/jmesmon/rust-openssl.git","svn_url":"https://github.com/jmesmon/rust-openssl","homepage":"","size":1262,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"sfackler:master","ref":"master","sha":"7610804c9d861455d118e60f62e4beb96a064598","user":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars.githubusercontent.com/u/1455697?v=3","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"repo":{"id":15500883,"name":"rust-openssl","full_name":"sfackler/rust-openssl","owner":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars.githubusercontent.com/u/1455697?v=3","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sfackler/rust-openssl","description":"OpenSSL bindings for Rust","fork":false,"url":"https://api.github.com/repos/sfackler/rust-openssl","forks_url":"https://api.github.com/repos/sfackler/rust-openssl/forks","keys_url":"https://api.github.com/repos/sfackler/rust-openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sfackler/rust-openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sfackler/rust-openssl/teams","hooks_url":"https://api.github.com/repos/sfackler/rust-openssl/hooks","issue_events_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/events{/number}","events_url":"https://api.github.com/repos/sfackler/rust-openssl/events","assignees_url":"https://api.github.com/repos/sfackler/rust-openssl/assignees{/user}","branches_url":"https://api.github.com/repos/sfackler/rust-openssl/branches{/branch}","tags_url":"https://api.github.com/repos/sfackler/rust-openssl/tags","blobs_url":"https://api.github.com/repos/sfackler/rust-openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sfackler/rust-openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sfackler/rust-openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/sfackler/rust-openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sfackler/rust-openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/sfackler/rust-openssl/languages","stargazers_url":"https://api.github.com/repos/sfackler/rust-openssl/stargazers","contributors_url":"https://api.github.com/repos/sfackler/rust-openssl/contributors","subscribers_url":"https://api.github.com/repos/sfackler/rust-openssl/subscribers","subscription_url":"https://api.github.com/repos/sfackler/rust-openssl/subscription","commits_url":"https://api.github.com/repos/sfackler/rust-openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/sfackler/rust-openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/sfackler/rust-openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/sfackler/rust-openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/sfackler/rust-openssl/contents/{+path}","compare_url":"https://api.github.com/repos/sfackler/rust-openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sfackler/rust-openssl/merges","archive_url":"https://api.github.com/repos/sfackler/rust-openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sfackler/rust-openssl/downloads","issues_url":"https://api.github.com/repos/sfackler/rust-openssl/issues{/number}","pulls_url":"https://api.github.com/repos/sfackler/rust-openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/sfackler/rust-openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/sfackler/rust-openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sfackler/rust-openssl/labels{/name}","releases_url":"https://api.github.com/repos/sfackler/rust-openssl/releases{/id}","deployments_url":"https://api.github.com/repos/sfackler/rust-openssl/deployments","created_at":"2013-12-28T23:56:50Z","updated_at":"2016-01-21T03:21:33Z","pushed_at":"2016-01-26T16:03:48Z","git_url":"git://github.com/sfackler/rust-openssl.git","ssh_url":"git@github.com:sfackler/rust-openssl.git","clone_url":"https://github.com/sfackler/rust-openssl.git","svn_url":"https://github.com/sfackler/rust-openssl","homepage":"","size":8372,"stargazers_count":143,"watchers_count":143,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":31,"forks":108,"open_issues":31,"watchers":143,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341"},"html":{"href":"https://github.com/sfackler/rust-openssl/pull/341"},"issue":{"href":"https://api.github.com/repos/sfackler/rust-openssl/issues/341"},"comments":{"href":"https://api.github.com/repos/sfackler/rust-openssl/issues/341/comments"},"review_comments":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341/comments"},"review_comment":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sfackler/rust-openssl/pulls/341/commits"},"statuses":{"href":"https://api.github.com/repos/sfackler/rust-openssl/statuses/c2d84cc532fff64371a02b5c42df4849f5ab472d"}}}}