{"action":"created","comment":{"url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/comments/212206683","pull_request_review_id":148786563,"id":212206683,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjIwNjY4Mw==","diff_hunk":"@@ -103,3 +103,36 @@ def connect(self):\n         )\n         serv.setName(name)\n         serv.setServiceParent(self)\n+\n+\n+def _ssl_context_factory(parameters):\n+    \"\"\"\n+    Produce a Twisted SSL context object from a pika connection parameter object.\n+    This is necessary as Twisted manages the connection, not Pika.\n+\n+    Args:\n+        parameters (pika.ConnectionParameters): The connection parameters built\n+            from the fedora_messaging configuration.\n+    \"\"\"\n+    client_cert = None\n+    key = config.conf[\"tls\"][\"keyfile\"]\n+    cert = config.conf[\"tls\"][\"certfile\"]\n+    with open(config.conf[\"tls\"][\"ca_cert\"]) as fd:\n+        ca_cert = ssl.Certificate.loadPEM(fd.read())\n+    if key and cert:\n+        # Note that _configure_tls_parameters sets the auth mode to EXTERNAL\n+        # if both key and cert are defined, so we don't need to do that here.\n+        with open(key) as fd:\n+            client_keypair = fd.read()\n+        with open(cert) as fd:\n+            client_keypair += fd.read()\n+        client_cert = ssl.PrivateCertificate.loadPEM(client_keypair)\n+\n+    context_factory = ssl.optionsForClientTLS(\n+        parameters.host,\n+        trustRoot=ca_cert,\n+        clientCertificate=client_cert,\n+        extraCertificateOptions={\"raiseMinimumTo\": ssl.TLSVersion.TLSv1_2},","path":"fedora_messaging/twisted/service.py","position":42,"original_position":42,"commit_id":"e83bf6e060afef148d375ce41f1f4e70039942b0","original_commit_id":"e83bf6e060afef148d375ce41f1f4e70039942b0","user":{"login":"puiterwijk","id":967561,"node_id":"MDQ6VXNlcjk2NzU2MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/967561?v=4","gravatar_id":"","url":"https://api.github.com/users/puiterwijk","html_url":"https://github.com/puiterwijk","followers_url":"https://api.github.com/users/puiterwijk/followers","following_url":"https://api.github.com/users/puiterwijk/following{/other_user}","gists_url":"https://api.github.com/users/puiterwijk/gists{/gist_id}","starred_url":"https://api.github.com/users/puiterwijk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puiterwijk/subscriptions","organizations_url":"https://api.github.com/users/puiterwijk/orgs","repos_url":"https://api.github.com/users/puiterwijk/repos","events_url":"https://api.github.com/users/puiterwijk/events{/privacy}","received_events_url":"https://api.github.com/users/puiterwijk/received_events","type":"User","site_admin":false},"body":"Nice! 🎉 ","created_at":"2018-08-23T07:26:21Z","updated_at":"2018-08-23T07:26:21Z","html_url":"https://github.com/fedora-infra/fedora-messaging/pull/35#discussion_r212206683","pull_request_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/comments/212206683"},"html":{"href":"https://github.com/fedora-infra/fedora-messaging/pull/35#discussion_r212206683"},"pull_request":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35","id":209967733,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5OTY3NzMz","html_url":"https://github.com/fedora-infra/fedora-messaging/pull/35","diff_url":"https://github.com/fedora-infra/fedora-messaging/pull/35.diff","patch_url":"https://github.com/fedora-infra/fedora-messaging/pull/35.patch","issue_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/35","number":35,"state":"open","locked":false,"title":"Add support for client x509 authentication in Twisted","user":{"login":"jeremycline","id":1977525,"node_id":"MDQ6VXNlcjE5Nzc1MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1977525?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"body":"Create the connection with a client certificate, if configured to do so.\r\n\r\n@abompard As an aside, what do you think about taking something like this and getting it into upstream pika? It seems like if the SSL context has client certs set, we should automatically be a) setting auth to EXTERNAL, and b) producing the correct twisted connection parameters from the pika parameters.","created_at":"2018-08-21T21:58:19Z","updated_at":"2018-08-23T07:26:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ad34b4243e038cd63141f0259403117bcab3af45","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"Fedmsg Maintainers","id":2183360,"node_id":"MDQ6VGVhbTIxODMzNjA=","slug":"fedmsg-maintainers","description":"","privacy":"closed","url":"https://api.github.com/teams/2183360","members_url":"https://api.github.com/teams/2183360/members{/member}","repositories_url":"https://api.github.com/teams/2183360/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35/commits","review_comments_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35/comments","review_comment_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/35/comments","statuses_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/statuses/e83bf6e060afef148d375ce41f1f4e70039942b0","head":{"label":"jeremycline:twisted-tls","ref":"twisted-tls","sha":"e83bf6e060afef148d375ce41f1f4e70039942b0","user":{"login":"jeremycline","id":1977525,"node_id":"MDQ6VXNlcjE5Nzc1MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1977525?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"repo":{"id":139491753,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk0OTE3NTM=","name":"fedora-messaging","full_name":"jeremycline/fedora-messaging","owner":{"login":"jeremycline","id":1977525,"node_id":"MDQ6VXNlcjE5Nzc1MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1977525?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremycline","html_url":"https://github.com/jeremycline","followers_url":"https://api.github.com/users/jeremycline/followers","following_url":"https://api.github.com/users/jeremycline/following{/other_user}","gists_url":"https://api.github.com/users/jeremycline/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremycline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremycline/subscriptions","organizations_url":"https://api.github.com/users/jeremycline/orgs","repos_url":"https://api.github.com/users/jeremycline/repos","events_url":"https://api.github.com/users/jeremycline/events{/privacy}","received_events_url":"https://api.github.com/users/jeremycline/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremycline/fedora-messaging","description":"A library for sending AMQP messages with JSON schema in Fedora infrastructure","fork":true,"url":"https://api.github.com/repos/jeremycline/fedora-messaging","forks_url":"https://api.github.com/repos/jeremycline/fedora-messaging/forks","keys_url":"https://api.github.com/repos/jeremycline/fedora-messaging/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremycline/fedora-messaging/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremycline/fedora-messaging/teams","hooks_url":"https://api.github.com/repos/jeremycline/fedora-messaging/hooks","issue_events_url":"https://api.github.com/repos/jeremycline/fedora-messaging/issues/events{/number}","events_url":"https://api.github.com/repos/jeremycline/fedora-messaging/events","assignees_url":"https://api.github.com/repos/jeremycline/fedora-messaging/assignees{/user}","branches_url":"https://api.github.com/repos/jeremycline/fedora-messaging/branches{/branch}","tags_url":"https://api.github.com/repos/jeremycline/fedora-messaging/tags","blobs_url":"https://api.github.com/repos/jeremycline/fedora-messaging/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremycline/fedora-messaging/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremycline/fedora-messaging/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremycline/fedora-messaging/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremycline/fedora-messaging/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremycline/fedora-messaging/languages","stargazers_url":"https://api.github.com/repos/jeremycline/fedora-messaging/stargazers","contributors_url":"https://api.github.com/repos/jeremycline/fedora-messaging/contributors","subscribers_url":"https://api.github.com/repos/jeremycline/fedora-messaging/subscribers","subscription_url":"https://api.github.com/repos/jeremycline/fedora-messaging/subscription","commits_url":"https://api.github.com/repos/jeremycline/fedora-messaging/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremycline/fedora-messaging/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremycline/fedora-messaging/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremycline/fedora-messaging/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremycline/fedora-messaging/contents/{+path}","compare_url":"https://api.github.com/repos/jeremycline/fedora-messaging/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremycline/fedora-messaging/merges","archive_url":"https://api.github.com/repos/jeremycline/fedora-messaging/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremycline/fedora-messaging/downloads","issues_url":"https://api.github.com/repos/jeremycline/fedora-messaging/issues{/number}","pulls_url":"https://api.github.com/repos/jeremycline/fedora-messaging/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremycline/fedora-messaging/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremycline/fedora-messaging/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremycline/fedora-messaging/labels{/name}","releases_url":"https://api.github.com/repos/jeremycline/fedora-messaging/releases{/id}","deployments_url":"https://api.github.com/repos/jeremycline/fedora-messaging/deployments","created_at":"2018-07-02T20:35:49Z","updated_at":"2018-07-02T20:35:51Z","pushed_at":"2018-08-23T07:15:11Z","git_url":"git://github.com/jeremycline/fedora-messaging.git","ssh_url":"git@github.com:jeremycline/fedora-messaging.git","clone_url":"https://github.com/jeremycline/fedora-messaging.git","svn_url":"https://github.com/jeremycline/fedora-messaging","homepage":"","size":326,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fedora-infra:master","ref":"master","sha":"e5cf89d3d965917ca98bbf90277fff825f16bc8a","user":{"login":"fedora-infra","id":3316637,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMTY2Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/3316637?v=4","gravatar_id":"","url":"https://api.github.com/users/fedora-infra","html_url":"https://github.com/fedora-infra","followers_url":"https://api.github.com/users/fedora-infra/followers","following_url":"https://api.github.com/users/fedora-infra/following{/other_user}","gists_url":"https://api.github.com/users/fedora-infra/gists{/gist_id}","starred_url":"https://api.github.com/users/fedora-infra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedora-infra/subscriptions","organizations_url":"https://api.github.com/users/fedora-infra/orgs","repos_url":"https://api.github.com/users/fedora-infra/repos","events_url":"https://api.github.com/users/fedora-infra/events{/privacy}","received_events_url":"https://api.github.com/users/fedora-infra/received_events","type":"Organization","site_admin":false},"repo":{"id":132087972,"node_id":"MDEwOlJlcG9zaXRvcnkxMzIwODc5NzI=","name":"fedora-messaging","full_name":"fedora-infra/fedora-messaging","owner":{"login":"fedora-infra","id":3316637,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMTY2Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/3316637?v=4","gravatar_id":"","url":"https://api.github.com/users/fedora-infra","html_url":"https://github.com/fedora-infra","followers_url":"https://api.github.com/users/fedora-infra/followers","following_url":"https://api.github.com/users/fedora-infra/following{/other_user}","gists_url":"https://api.github.com/users/fedora-infra/gists{/gist_id}","starred_url":"https://api.github.com/users/fedora-infra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedora-infra/subscriptions","organizations_url":"https://api.github.com/users/fedora-infra/orgs","repos_url":"https://api.github.com/users/fedora-infra/repos","events_url":"https://api.github.com/users/fedora-infra/events{/privacy}","received_events_url":"https://api.github.com/users/fedora-infra/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fedora-infra/fedora-messaging","description":"A library for sending AMQP messages with JSON schema in Fedora infrastructure","fork":false,"url":"https://api.github.com/repos/fedora-infra/fedora-messaging","forks_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/forks","keys_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/teams","hooks_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/hooks","issue_events_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/events{/number}","events_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/events","assignees_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/assignees{/user}","branches_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/branches{/branch}","tags_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/tags","blobs_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/statuses/{sha}","languages_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/languages","stargazers_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/stargazers","contributors_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/contributors","subscribers_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/subscribers","subscription_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/subscription","commits_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/contents/{+path}","compare_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/merges","archive_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/downloads","issues_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues{/number}","pulls_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls{/number}","milestones_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/milestones{/number}","notifications_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/labels{/name}","releases_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/releases{/id}","deployments_url":"https://api.github.com/repos/fedora-infra/fedora-messaging/deployments","created_at":"2018-05-04T04:42:33Z","updated_at":"2018-08-23T07:24:10Z","pushed_at":"2018-08-23T07:24:09Z","git_url":"git://github.com/fedora-infra/fedora-messaging.git","ssh_url":"git@github.com:fedora-infra/fedora-messaging.git","clone_url":"https://github.com/fedora-infra/fedora-messaging.git","svn_url":"https://github.com/fedora-infra/fedora-messaging","homepage":"","size":300,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":5,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35"},"html":{"href":"https://github.com/fedora-infra/fedora-messaging/pull/35"},"issue":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/35"},"comments":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/fedora-infra/fedora-messaging/statuses/e83bf6e060afef148d375ce41f1f4e70039942b0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"puiterwijk"}}