{"action":"created","comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/66030666","id":66030666,"diff_hunk":"@@ -0,0 +1,99 @@\n+require \"spec\"\n+require \"openssl/ssl/hostname_validation\"\n+\n+def openssl_create_cert(subject = nil, san = nil)\n+  cert = OpenSSL::X509::Certificate.new\n+  cert.subject = subject if subject\n+  cert.add_extension(OpenSSL::X509::Extension.new(\"subjectAltName\", san)) if san\n+  cert.to_unsafe\n+end\n+\n+describe OpenSSL::SSL::HostnameValidation do\n+  describe \"validate_hostname\" do\n+    it \"matches IP from certificate SAN entries\" do\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"192.168.1.1\", openssl_create_cert(san: \"IP:192.168.1.1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"192.168.1.2\", openssl_create_cert(san: \"IP:192.168.1.1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchNotFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"::1\", openssl_create_cert(san: \"IP:::1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"::1\", openssl_create_cert(san: \"IP:::2\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchNotFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"0:0:0:0:0:0:0:1\", openssl_create_cert(san: \"IP:::1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"fe80:0:0:0:0:0:0:1\", openssl_create_cert(san: \"IP:fe80::1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"fe80:0:0:0:0:0:0:2\", openssl_create_cert(san: \"IP:fe80::1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchNotFound)\n+      OpenSSL::SSL::HostnameValidation.validate_hostname(\"fe80:0:1\", openssl_create_cert(san: \"IP:fe80:0::1\")).should eq(OpenSSL::SSL::HostnameValidation::Result::MatchNotFound)","path":"spec/std/openssl/ssl/hostname_validation_spec.cr","position":21,"original_position":21,"commit_id":"f050e96500d2e5c38933a82722baa0af31b7424d","original_commit_id":"f050e96500d2e5c38933a82722baa0af31b7424d","user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"body":"Argh. Typo.","created_at":"2016-06-07T08:40:47Z","updated_at":"2016-06-07T08:40:47Z","html_url":"https://github.com/crystal-lang/crystal/pull/2734#discussion_r66030666","pull_request_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734","_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments/66030666"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/2734#discussion_r66030666"},"pull_request":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734"}}},"pull_request":{"url":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734","id":72533649,"html_url":"https://github.com/crystal-lang/crystal/pull/2734","diff_url":"https://github.com/crystal-lang/crystal/pull/2734.diff","patch_url":"https://github.com/crystal-lang/crystal/pull/2734.patch","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2734","number":2734,"state":"open","locked":false,"title":"Legacy TLS hostname validation (OpenSSL < 1.0.2)","user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"body":"closes #2717\r\n\r\nThis went a little too well: the manual badssl specs passed first time. This is weird. Also, there is no verification that the Common Name match does work, indeed. Maybe we could add specs with a few certificates with or without SAN entries to verify the methods actually work correctly (in isolation).\r\n\r\nNote: I introduced a `Socket.ip?(str)` method to validate IPv4 and IPv6 addresses. Maybe we'd like a better format. The implementation relies on the POSIX `inet_pton` function, which I expect to be faster than a regular expression.","created_at":"2016-06-03T16:23:52Z","updated_at":"2016-06-07T08:40:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b0b216747e2b5728edc175e4d6d2390ef309fff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734/commits","review_comments_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734/comments","review_comment_url":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2734/comments","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/f050e96500d2e5c38933a82722baa0af31b7424d","head":{"label":"ysbaddaden:openssl-legacy-verify-certificate-hostname","ref":"openssl-legacy-verify-certificate-hostname","sha":"f050e96500d2e5c38933a82722baa0af31b7424d","user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"repo":{"id":28955723,"name":"crystal","full_name":"ysbaddaden/crystal","owner":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ysbaddaden/crystal","description":"The Crystal Programming Language","fork":true,"url":"https://api.github.com/repos/ysbaddaden/crystal","forks_url":"https://api.github.com/repos/ysbaddaden/crystal/forks","keys_url":"https://api.github.com/repos/ysbaddaden/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ysbaddaden/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ysbaddaden/crystal/teams","hooks_url":"https://api.github.com/repos/ysbaddaden/crystal/hooks","issue_events_url":"https://api.github.com/repos/ysbaddaden/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/ysbaddaden/crystal/events","assignees_url":"https://api.github.com/repos/ysbaddaden/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/ysbaddaden/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/ysbaddaden/crystal/tags","blobs_url":"https://api.github.com/repos/ysbaddaden/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ysbaddaden/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ysbaddaden/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/ysbaddaden/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ysbaddaden/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/ysbaddaden/crystal/languages","stargazers_url":"https://api.github.com/repos/ysbaddaden/crystal/stargazers","contributors_url":"https://api.github.com/repos/ysbaddaden/crystal/contributors","subscribers_url":"https://api.github.com/repos/ysbaddaden/crystal/subscribers","subscription_url":"https://api.github.com/repos/ysbaddaden/crystal/subscription","commits_url":"https://api.github.com/repos/ysbaddaden/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/ysbaddaden/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/ysbaddaden/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/ysbaddaden/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/ysbaddaden/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/ysbaddaden/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ysbaddaden/crystal/merges","archive_url":"https://api.github.com/repos/ysbaddaden/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ysbaddaden/crystal/downloads","issues_url":"https://api.github.com/repos/ysbaddaden/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/ysbaddaden/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/ysbaddaden/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/ysbaddaden/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ysbaddaden/crystal/labels{/name}","releases_url":"https://api.github.com/repos/ysbaddaden/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/ysbaddaden/crystal/deployments","created_at":"2015-01-08T08:08:48Z","updated_at":"2016-01-21T10:58:49Z","pushed_at":"2016-06-07T08:24:07Z","git_url":"git://github.com/ysbaddaden/crystal.git","ssh_url":"git@github.com:ysbaddaden/crystal.git","clone_url":"https://github.com/ysbaddaden/crystal.git","svn_url":"https://github.com/ysbaddaden/crystal","homepage":"http://crystal-lang.org","size":33172,"stargazers_count":0,"watchers_count":0,"language":"Crystal","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":"crystal-lang:master","ref":"master","sha":"3d20332a9e3de05d1722814477aa218cc34f1a25","user":{"login":"crystal-lang","id":6539796,"avatar_url":"https://avatars.githubusercontent.com/u/6539796?v=3","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":6887813,"name":"crystal","full_name":"crystal-lang/crystal","owner":{"login":"crystal-lang","id":6539796,"avatar_url":"https://avatars.githubusercontent.com/u/6539796?v=3","gravatar_id":"","url":"https://api.github.com/users/crystal-lang","html_url":"https://github.com/crystal-lang","followers_url":"https://api.github.com/users/crystal-lang/followers","following_url":"https://api.github.com/users/crystal-lang/following{/other_user}","gists_url":"https://api.github.com/users/crystal-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/crystal-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crystal-lang/subscriptions","organizations_url":"https://api.github.com/users/crystal-lang/orgs","repos_url":"https://api.github.com/users/crystal-lang/repos","events_url":"https://api.github.com/users/crystal-lang/events{/privacy}","received_events_url":"https://api.github.com/users/crystal-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crystal-lang/crystal","description":"The Crystal Programming Language","fork":false,"url":"https://api.github.com/repos/crystal-lang/crystal","forks_url":"https://api.github.com/repos/crystal-lang/crystal/forks","keys_url":"https://api.github.com/repos/crystal-lang/crystal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crystal-lang/crystal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crystal-lang/crystal/teams","hooks_url":"https://api.github.com/repos/crystal-lang/crystal/hooks","issue_events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/events{/number}","events_url":"https://api.github.com/repos/crystal-lang/crystal/events","assignees_url":"https://api.github.com/repos/crystal-lang/crystal/assignees{/user}","branches_url":"https://api.github.com/repos/crystal-lang/crystal/branches{/branch}","tags_url":"https://api.github.com/repos/crystal-lang/crystal/tags","blobs_url":"https://api.github.com/repos/crystal-lang/crystal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crystal-lang/crystal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crystal-lang/crystal/git/refs{/sha}","trees_url":"https://api.github.com/repos/crystal-lang/crystal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crystal-lang/crystal/statuses/{sha}","languages_url":"https://api.github.com/repos/crystal-lang/crystal/languages","stargazers_url":"https://api.github.com/repos/crystal-lang/crystal/stargazers","contributors_url":"https://api.github.com/repos/crystal-lang/crystal/contributors","subscribers_url":"https://api.github.com/repos/crystal-lang/crystal/subscribers","subscription_url":"https://api.github.com/repos/crystal-lang/crystal/subscription","commits_url":"https://api.github.com/repos/crystal-lang/crystal/commits{/sha}","git_commits_url":"https://api.github.com/repos/crystal-lang/crystal/git/commits{/sha}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/comments{/number}","issue_comment_url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments{/number}","contents_url":"https://api.github.com/repos/crystal-lang/crystal/contents/{+path}","compare_url":"https://api.github.com/repos/crystal-lang/crystal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crystal-lang/crystal/merges","archive_url":"https://api.github.com/repos/crystal-lang/crystal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crystal-lang/crystal/downloads","issues_url":"https://api.github.com/repos/crystal-lang/crystal/issues{/number}","pulls_url":"https://api.github.com/repos/crystal-lang/crystal/pulls{/number}","milestones_url":"https://api.github.com/repos/crystal-lang/crystal/milestones{/number}","notifications_url":"https://api.github.com/repos/crystal-lang/crystal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crystal-lang/crystal/labels{/name}","releases_url":"https://api.github.com/repos/crystal-lang/crystal/releases{/id}","deployments_url":"https://api.github.com/repos/crystal-lang/crystal/deployments","created_at":"2012-11-27T17:32:32Z","updated_at":"2016-06-06T22:05:40Z","pushed_at":"2016-06-07T08:24:08Z","git_url":"git://github.com/crystal-lang/crystal.git","ssh_url":"git@github.com:crystal-lang/crystal.git","clone_url":"https://github.com/crystal-lang/crystal.git","svn_url":"https://github.com/crystal-lang/crystal","homepage":"http://crystal-lang.org","size":61365,"stargazers_count":5112,"watchers_count":5112,"language":"Crystal","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":418,"mirror_url":null,"open_issues_count":229,"forks":418,"open_issues":229,"watchers":5112,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734"},"html":{"href":"https://github.com/crystal-lang/crystal/pull/2734"},"issue":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/2734"},"comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/issues/2734/comments"},"review_comments":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734/comments"},"review_comment":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crystal-lang/crystal/pulls/2734/commits"},"statuses":{"href":"https://api.github.com/repos/crystal-lang/crystal/statuses/f050e96500d2e5c38933a82722baa0af31b7424d"}}}}
{"actor":{"display_login":"ysbaddaden"}}