{"action":"created","comment":{"url":"https://api.github.com/repos/pyca/cryptography/pulls/comments/28745503","id":28745503,"diff_hunk":"@@ -57,6 +63,89 @@ def _build_x509_name(backend, x509_name):\n     return x509.Name(attributes)\n \n \n+def _build_general_name(backend, gn):\n+    # dNSName\n+    if gn.type == 2:\n+        data = backend._ffi.buffer(\n+            gn.d.dNSName.data, gn.d.dNSName.length\n+        )[:].decode(\"ascii\")\n+        value = x509.DNSName(idna.decode(data))\n+    # dirName\n+    elif gn.type == 4:\n+        value = x509.DirectoryName(\n+            _build_x509_name(backend, gn.d.directoryName)\n+        )\n+    # uniformResourceIdentifier\n+    elif gn.type == 6:\n+        data = backend._ffi.buffer(\n+            gn.d.uniformResourceIdentifier.data,\n+            gn.d.uniformResourceIdentifier.length\n+        )[:].decode(\"ascii\")\n+        parsed = urllib_parse.urlparse(data)\n+        hostname = idna.decode(parsed.hostname)\n+        if parsed.port:\n+            netloc = hostname + u\":\" + str(parsed.port)\n+        else:\n+            netloc = hostname\n+\n+        # Note that building a URL in this fashion means it should be\n+        # semantically indistinguishable from the original but is not\n+        # guaranteed to be exactly the same.\n+        uri = urllib_parse.urlunparse((\n+            parsed.scheme,\n+            netloc,\n+            parsed.path,\n+            parsed.params,\n+            parsed.query,\n+            parsed.fragment\n+        ))\n+        value = x509.UniformResourceIdentifier(uri)\n+    # rfc822Name\n+    elif gn.type == 1:\n+        data = backend._ffi.buffer(\n+            gn.d.rfc822Name.data, gn.d.rfc822Name.length\n+        )[:].decode(\"ascii\")\n+        parsed = parseaddr(data)\n+        if parsed[1]:\n+            parts = parsed[1].split(\"@\")\n+            assert len(parts) <= 2\n+            if len(parts) == 1:\n+                value = x509.RFC822Name(data)\n+            elif parsed[0]:\n+                value = x509.RFC822Name(\n+                    parsed[0] + u\" <\" + parts[0] +\n+                    u\"@\" + idna.decode(parts[1]) + u\">\"\n+                )\n+            else:\n+                value = x509.RFC822Name(\n+                    parts[0] + u\"@\" + idna.decode(parts[1])\n+                )\n+        else:\n+            value = x509.RFC822Name(data)\n+    # iPAddress\n+    elif gn.type == 7:\n+        value = x509.IPAddress(\n+            ipaddress.ip_address(\n+                backend._ffi.buffer(\n+                    gn.d.iPAddress.data, gn.d.iPAddress.length\n+                )[:]\n+            )\n+        )\n+    # registeredID\n+    elif gn.type == 8:\n+        oid = _obj2txt(backend, gn.d.registeredID)\n+        value = x509.RegisteredID(x509.ObjectIdentifier(oid))\n+    else:\n+        # otherName, x400Address or ediPartyName\n+        raise x509.UnsupportedGeneralNameType(\n+            \"{0} is not a supported type\".format(\n+                x509._GENERAL_NAMES[gn.type]","path":"src/cryptography/hazmat/backends/openssl/x509.py","position":93,"original_position":93,"commit_id":"060a4c6e53f3173458027e79ff79748f5f5d7b3a","original_commit_id":"060a4c6e53f3173458027e79ff79748f5f5d7b3a","user":{"login":"alex","id":772,"avatar_url":"https://avatars.githubusercontent.com/u/772?v=3","gravatar_id":"","url":"https://api.github.com/users/alex","html_url":"https://github.com/alex","followers_url":"https://api.github.com/users/alex/followers","following_url":"https://api.github.com/users/alex/following{/other_user}","gists_url":"https://api.github.com/users/alex/gists{/gist_id}","starred_url":"https://api.github.com/users/alex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex/subscriptions","organizations_url":"https://api.github.com/users/alex/orgs","repos_url":"https://api.github.com/users/alex/repos","events_url":"https://api.github.com/users/alex/events{/privacy}","received_events_url":"https://api.github.com/users/alex/received_events","type":"User","site_admin":false},"body":"I was thinking just drop the text, number only. Simplicity or something.\n\nOn Mon, Apr 20, 2015 at 10:13 PM, Paul Kehrer <notifications@github.com>\nwrote:\n\n> In src/cryptography/hazmat/backends/openssl/x509.py\n> <https://github.com/pyca/cryptography/pull/1855#discussion_r28745483>:\n>\n> > +        value = x509.IPAddress(\n> > +            ipaddress.ip_address(\n> > +                backend._ffi.buffer(\n> > +                    gn.d.iPAddress.data, gn.d.iPAddress.length\n> > +                )[:]\n> > +            )\n> > +        )\n> > +    # registeredID\n> > +    elif gn.type == 8:\n> > +        oid = _obj2txt(backend, gn.d.registeredID)\n> > +        value = x509.RegisteredID(x509.ObjectIdentifier(oid))\n> > +    else:\n> > +        # otherName, x400Address or ediPartyName\n> > +        raise x509.UnsupportedGeneralNameType(\n> > +            \"{0} is not a supported type\".format(\n> > +                x509._GENERAL_NAMES[gn.type]\n>\n> Probably not. I could do .get on this to handle that case and just have it\n> return the number then?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/pyca/cryptography/pull/1855/files#r28745483>.\n>\n\n\n\n-- \n\"I disapprove of what you say, but I will defend to the death your right to\nsay it.\" -- Evelyn Beatrice Hall (summarizing Voltaire)\n\"The people's good is the highest law.\" -- Cicero\nGPG Key fingerprint: 125F 5C67 DFE9 4084\n","created_at":"2015-04-21T02:13:54Z","updated_at":"2015-04-21T02:13:54Z","html_url":"https://github.com/pyca/cryptography/pull/1855#discussion_r28745503","pull_request_url":"https://api.github.com/repos/pyca/cryptography/pulls/1855","_links":{"self":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/comments/28745503"},"html":{"href":"https://github.com/pyca/cryptography/pull/1855#discussion_r28745503"},"pull_request":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/1855"}}},"pull_request":{"url":"https://api.github.com/repos/pyca/cryptography/pulls/1855","id":33700813,"html_url":"https://github.com/pyca/cryptography/pull/1855","diff_url":"https://github.com/pyca/cryptography/pull/1855.diff","patch_url":"https://github.com/pyca/cryptography/pull/1855.patch","issue_url":"https://api.github.com/repos/pyca/cryptography/issues/1855","number":1855,"state":"open","locked":false,"title":"Support Subject Alternative Name in the OpenSSL backend","user":{"login":"reaperhulk","id":161495,"avatar_url":"https://avatars.githubusercontent.com/u/161495?v=3","gravatar_id":"","url":"https://api.github.com/users/reaperhulk","html_url":"https://github.com/reaperhulk","followers_url":"https://api.github.com/users/reaperhulk/followers","following_url":"https://api.github.com/users/reaperhulk/following{/other_user}","gists_url":"https://api.github.com/users/reaperhulk/gists{/gist_id}","starred_url":"https://api.github.com/users/reaperhulk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reaperhulk/subscriptions","organizations_url":"https://api.github.com/users/reaperhulk/orgs","repos_url":"https://api.github.com/users/reaperhulk/repos","events_url":"https://api.github.com/users/reaperhulk/events{/privacy}","received_events_url":"https://api.github.com/users/reaperhulk/received_events","type":"User","site_admin":false},"body":"This PR adds [idna](https://github.com/kjd/idna) as a dependency.\r\n\r\nOne item to discuss here is whether we want to actually represent UniformResourceIdentifiers as strings or if we should document the value as a ParseResult from urlparse.\r\n\r\nrequires #1854 \r\nrefs #1743 ","created_at":"2015-04-20T20:04:57Z","updated_at":"2015-04-21T02:13:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a4cc680b3ca30685b66b718982e2079a4d7429d","assignee":null,"milestone":{"url":"https://api.github.com/repos/pyca/cryptography/milestones/10","html_url":"https://github.com/pyca/cryptography/milestones/Ninth%20Release","labels_url":"https://api.github.com/repos/pyca/cryptography/milestones/10/labels","id":987787,"number":10,"title":"Ninth Release","description":"","creator":{"login":"reaperhulk","id":161495,"avatar_url":"https://avatars.githubusercontent.com/u/161495?v=3","gravatar_id":"","url":"https://api.github.com/users/reaperhulk","html_url":"https://github.com/reaperhulk","followers_url":"https://api.github.com/users/reaperhulk/followers","following_url":"https://api.github.com/users/reaperhulk/following{/other_user}","gists_url":"https://api.github.com/users/reaperhulk/gists{/gist_id}","starred_url":"https://api.github.com/users/reaperhulk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reaperhulk/subscriptions","organizations_url":"https://api.github.com/users/reaperhulk/orgs","repos_url":"https://api.github.com/users/reaperhulk/repos","events_url":"https://api.github.com/users/reaperhulk/events{/privacy}","received_events_url":"https://api.github.com/users/reaperhulk/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":58,"state":"open","created_at":"2015-02-20T03:00:23Z","updated_at":"2015-04-20T20:05:02Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/pyca/cryptography/pulls/1855/commits","review_comments_url":"https://api.github.com/repos/pyca/cryptography/pulls/1855/comments","review_comment_url":"https://api.github.com/repos/pyca/cryptography/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyca/cryptography/issues/1855/comments","statuses_url":"https://api.github.com/repos/pyca/cryptography/statuses/060a4c6e53f3173458027e79ff79748f5f5d7b3a","head":{"label":"reaperhulk:subject-alt-name","ref":"subject-alt-name","sha":"060a4c6e53f3173458027e79ff79748f5f5d7b3a","user":{"login":"reaperhulk","id":161495,"avatar_url":"https://avatars.githubusercontent.com/u/161495?v=3","gravatar_id":"","url":"https://api.github.com/users/reaperhulk","html_url":"https://github.com/reaperhulk","followers_url":"https://api.github.com/users/reaperhulk/followers","following_url":"https://api.github.com/users/reaperhulk/following{/other_user}","gists_url":"https://api.github.com/users/reaperhulk/gists{/gist_id}","starred_url":"https://api.github.com/users/reaperhulk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reaperhulk/subscriptions","organizations_url":"https://api.github.com/users/reaperhulk/orgs","repos_url":"https://api.github.com/users/reaperhulk/repos","events_url":"https://api.github.com/users/reaperhulk/events{/privacy}","received_events_url":"https://api.github.com/users/reaperhulk/received_events","type":"User","site_admin":false},"repo":{"id":12704352,"name":"cryptography","full_name":"reaperhulk/cryptography","owner":{"login":"reaperhulk","id":161495,"avatar_url":"https://avatars.githubusercontent.com/u/161495?v=3","gravatar_id":"","url":"https://api.github.com/users/reaperhulk","html_url":"https://github.com/reaperhulk","followers_url":"https://api.github.com/users/reaperhulk/followers","following_url":"https://api.github.com/users/reaperhulk/following{/other_user}","gists_url":"https://api.github.com/users/reaperhulk/gists{/gist_id}","starred_url":"https://api.github.com/users/reaperhulk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reaperhulk/subscriptions","organizations_url":"https://api.github.com/users/reaperhulk/orgs","repos_url":"https://api.github.com/users/reaperhulk/repos","events_url":"https://api.github.com/users/reaperhulk/events{/privacy}","received_events_url":"https://api.github.com/users/reaperhulk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/reaperhulk/cryptography","description":"cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.","fork":true,"url":"https://api.github.com/repos/reaperhulk/cryptography","forks_url":"https://api.github.com/repos/reaperhulk/cryptography/forks","keys_url":"https://api.github.com/repos/reaperhulk/cryptography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reaperhulk/cryptography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reaperhulk/cryptography/teams","hooks_url":"https://api.github.com/repos/reaperhulk/cryptography/hooks","issue_events_url":"https://api.github.com/repos/reaperhulk/cryptography/issues/events{/number}","events_url":"https://api.github.com/repos/reaperhulk/cryptography/events","assignees_url":"https://api.github.com/repos/reaperhulk/cryptography/assignees{/user}","branches_url":"https://api.github.com/repos/reaperhulk/cryptography/branches{/branch}","tags_url":"https://api.github.com/repos/reaperhulk/cryptography/tags","blobs_url":"https://api.github.com/repos/reaperhulk/cryptography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reaperhulk/cryptography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reaperhulk/cryptography/git/refs{/sha}","trees_url":"https://api.github.com/repos/reaperhulk/cryptography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reaperhulk/cryptography/statuses/{sha}","languages_url":"https://api.github.com/repos/reaperhulk/cryptography/languages","stargazers_url":"https://api.github.com/repos/reaperhulk/cryptography/stargazers","contributors_url":"https://api.github.com/repos/reaperhulk/cryptography/contributors","subscribers_url":"https://api.github.com/repos/reaperhulk/cryptography/subscribers","subscription_url":"https://api.github.com/repos/reaperhulk/cryptography/subscription","commits_url":"https://api.github.com/repos/reaperhulk/cryptography/commits{/sha}","git_commits_url":"https://api.github.com/repos/reaperhulk/cryptography/git/commits{/sha}","comments_url":"https://api.github.com/repos/reaperhulk/cryptography/comments{/number}","issue_comment_url":"https://api.github.com/repos/reaperhulk/cryptography/issues/comments{/number}","contents_url":"https://api.github.com/repos/reaperhulk/cryptography/contents/{+path}","compare_url":"https://api.github.com/repos/reaperhulk/cryptography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reaperhulk/cryptography/merges","archive_url":"https://api.github.com/repos/reaperhulk/cryptography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reaperhulk/cryptography/downloads","issues_url":"https://api.github.com/repos/reaperhulk/cryptography/issues{/number}","pulls_url":"https://api.github.com/repos/reaperhulk/cryptography/pulls{/number}","milestones_url":"https://api.github.com/repos/reaperhulk/cryptography/milestones{/number}","notifications_url":"https://api.github.com/repos/reaperhulk/cryptography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reaperhulk/cryptography/labels{/name}","releases_url":"https://api.github.com/repos/reaperhulk/cryptography/releases{/id}","created_at":"2013-09-09T14:59:27Z","updated_at":"2015-04-04T23:12:58Z","pushed_at":"2015-04-20T23:05:02Z","git_url":"git://github.com/reaperhulk/cryptography.git","ssh_url":"git@github.com:reaperhulk/cryptography.git","clone_url":"https://github.com/reaperhulk/cryptography.git","svn_url":"https://github.com/reaperhulk/cryptography","homepage":"","size":32971,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"pyca:master","ref":"master","sha":"bd11e028dcf763171097f5366f87f95ad0371a03","user":{"login":"pyca","id":5615737,"avatar_url":"https://avatars.githubusercontent.com/u/5615737?v=3","gravatar_id":"","url":"https://api.github.com/users/pyca","html_url":"https://github.com/pyca","followers_url":"https://api.github.com/users/pyca/followers","following_url":"https://api.github.com/users/pyca/following{/other_user}","gists_url":"https://api.github.com/users/pyca/gists{/gist_id}","starred_url":"https://api.github.com/users/pyca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyca/subscriptions","organizations_url":"https://api.github.com/users/pyca/orgs","repos_url":"https://api.github.com/users/pyca/repos","events_url":"https://api.github.com/users/pyca/events{/privacy}","received_events_url":"https://api.github.com/users/pyca/received_events","type":"Organization","site_admin":false},"repo":{"id":11939484,"name":"cryptography","full_name":"pyca/cryptography","owner":{"login":"pyca","id":5615737,"avatar_url":"https://avatars.githubusercontent.com/u/5615737?v=3","gravatar_id":"","url":"https://api.github.com/users/pyca","html_url":"https://github.com/pyca","followers_url":"https://api.github.com/users/pyca/followers","following_url":"https://api.github.com/users/pyca/following{/other_user}","gists_url":"https://api.github.com/users/pyca/gists{/gist_id}","starred_url":"https://api.github.com/users/pyca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyca/subscriptions","organizations_url":"https://api.github.com/users/pyca/orgs","repos_url":"https://api.github.com/users/pyca/repos","events_url":"https://api.github.com/users/pyca/events{/privacy}","received_events_url":"https://api.github.com/users/pyca/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyca/cryptography","description":"cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.","fork":false,"url":"https://api.github.com/repos/pyca/cryptography","forks_url":"https://api.github.com/repos/pyca/cryptography/forks","keys_url":"https://api.github.com/repos/pyca/cryptography/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyca/cryptography/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyca/cryptography/teams","hooks_url":"https://api.github.com/repos/pyca/cryptography/hooks","issue_events_url":"https://api.github.com/repos/pyca/cryptography/issues/events{/number}","events_url":"https://api.github.com/repos/pyca/cryptography/events","assignees_url":"https://api.github.com/repos/pyca/cryptography/assignees{/user}","branches_url":"https://api.github.com/repos/pyca/cryptography/branches{/branch}","tags_url":"https://api.github.com/repos/pyca/cryptography/tags","blobs_url":"https://api.github.com/repos/pyca/cryptography/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyca/cryptography/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyca/cryptography/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyca/cryptography/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyca/cryptography/statuses/{sha}","languages_url":"https://api.github.com/repos/pyca/cryptography/languages","stargazers_url":"https://api.github.com/repos/pyca/cryptography/stargazers","contributors_url":"https://api.github.com/repos/pyca/cryptography/contributors","subscribers_url":"https://api.github.com/repos/pyca/cryptography/subscribers","subscription_url":"https://api.github.com/repos/pyca/cryptography/subscription","commits_url":"https://api.github.com/repos/pyca/cryptography/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyca/cryptography/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyca/cryptography/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyca/cryptography/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyca/cryptography/contents/{+path}","compare_url":"https://api.github.com/repos/pyca/cryptography/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyca/cryptography/merges","archive_url":"https://api.github.com/repos/pyca/cryptography/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyca/cryptography/downloads","issues_url":"https://api.github.com/repos/pyca/cryptography/issues{/number}","pulls_url":"https://api.github.com/repos/pyca/cryptography/pulls{/number}","milestones_url":"https://api.github.com/repos/pyca/cryptography/milestones{/number}","notifications_url":"https://api.github.com/repos/pyca/cryptography/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyca/cryptography/labels{/name}","releases_url":"https://api.github.com/repos/pyca/cryptography/releases{/id}","created_at":"2013-08-07T02:23:38Z","updated_at":"2015-04-20T22:21:33Z","pushed_at":"2015-04-20T23:05:02Z","git_url":"git://github.com/pyca/cryptography.git","ssh_url":"git@github.com:pyca/cryptography.git","clone_url":"https://github.com/pyca/cryptography.git","svn_url":"https://github.com/pyca/cryptography","homepage":"https://cryptography.io/","size":41412,"stargazers_count":672,"watchers_count":672,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":94,"forks":143,"open_issues":94,"watchers":672,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/1855"},"html":{"href":"https://github.com/pyca/cryptography/pull/1855"},"issue":{"href":"https://api.github.com/repos/pyca/cryptography/issues/1855"},"comments":{"href":"https://api.github.com/repos/pyca/cryptography/issues/1855/comments"},"review_comments":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/1855/comments"},"review_comment":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyca/cryptography/pulls/1855/commits"},"statuses":{"href":"https://api.github.com/repos/pyca/cryptography/statuses/060a4c6e53f3173458027e79ff79748f5f5d7b3a"}}}}