{"action":"created","comment":{"url":"https://api.github.com/repos/openssl/openssl/pulls/comments/99029646","pull_request_review_id":19691818,"id":99029646,"diff_hunk":"@@ -1355,3 +1356,41 @@ void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose)\n     SSL_CTX_set_security_callback(ctx, security_callback_debug);\n     SSL_CTX_set0_security_ex_data(ctx, &sdb);\n }\n+\n+static void keylog_callback(const SSL *ssl, const char *line)\n+{\n+    /*\n+     * There might be concurrent writers to the keylog file, so we must ensure\n+     * that one line is written at once.\n+     */\n+    BIO_puts(bio_keylog, line);\n+    BIO_write(bio_keylog, \"\\n\", 1);\n+    (void)BIO_flush(bio_keylog);\n+}\n+\n+int set_keylog_file(SSL_CTX *ctx, const char *keylog_file)\n+{\n+    /* Close any open files */\n+    BIO_vfree(bio_keylog);\n+    bio_keylog = NULL;\n+\n+    if (ctx == NULL || keylog_file == NULL) {\n+        /* Keylogging is disabled, OK. */\n+        return 0;\n+    }\n+\n+    bio_keylog = BIO_new_file(keylog_file, \"a\");","path":"apps/s_cb.c","position":null,"original_position":35,"commit_id":"56c7569dfc6fbd2d9c717c8fe85fa0615b9da779","original_commit_id":"9b1605acb2929656a92b54b690dcc7cbfb2eec20","user":{"login":"levitte","id":698918,"avatar_url":"https://avatars.githubusercontent.com/u/698918?v=3","gravatar_id":"","url":"https://api.github.com/users/levitte","html_url":"https://github.com/levitte","followers_url":"https://api.github.com/users/levitte/followers","following_url":"https://api.github.com/users/levitte/following{/other_user}","gists_url":"https://api.github.com/users/levitte/gists{/gist_id}","starred_url":"https://api.github.com/users/levitte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/levitte/subscriptions","organizations_url":"https://api.github.com/users/levitte/orgs","repos_url":"https://api.github.com/users/levitte/repos","events_url":"https://api.github.com/users/levitte/events{/privacy}","received_events_url":"https://api.github.com/users/levitte/received_events","type":"User","site_admin":false},"body":"Okie","created_at":"2017-02-02T00:23:50Z","updated_at":"2017-02-02T00:23:50Z","html_url":"https://github.com/openssl/openssl/pull/2343#discussion_r99029646","pull_request_url":"https://api.github.com/repos/openssl/openssl/pulls/2343","_links":{"self":{"href":"https://api.github.com/repos/openssl/openssl/pulls/comments/99029646"},"html":{"href":"https://github.com/openssl/openssl/pull/2343#discussion_r99029646"},"pull_request":{"href":"https://api.github.com/repos/openssl/openssl/pulls/2343"}}},"pull_request":{"url":"https://api.github.com/repos/openssl/openssl/pulls/2343","id":104192455,"html_url":"https://github.com/openssl/openssl/pull/2343","diff_url":"https://github.com/openssl/openssl/pull/2343.diff","patch_url":"https://github.com/openssl/openssl/pull/2343.patch","issue_url":"https://api.github.com/repos/openssl/openssl/issues/2343","number":2343,"state":"open","locked":false,"title":"apps: Add support for writing a keylog file","user":{"login":"Lekensteyn","id":164530,"avatar_url":"https://avatars.githubusercontent.com/u/164530?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekensteyn","html_url":"https://github.com/Lekensteyn","followers_url":"https://api.github.com/users/Lekensteyn/followers","following_url":"https://api.github.com/users/Lekensteyn/following{/other_user}","gists_url":"https://api.github.com/users/Lekensteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekensteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekensteyn/subscriptions","organizations_url":"https://api.github.com/users/Lekensteyn/orgs","repos_url":"https://api.github.com/users/Lekensteyn/repos","events_url":"https://api.github.com/users/Lekensteyn/events{/privacy}","received_events_url":"https://api.github.com/users/Lekensteyn/received_events","type":"User","site_admin":false},"body":"##### Checklist\r\n- [x] documentation is added or updated\r\n- [ ] tests are added or updated\r\n\r\n##### Description of change\r\nThis is a quick patch to test #2287. I will probably copy the same code to `s_server` once it is ready (or is there a better way to share code?).\r\n\r\n<del>Observations (hence RFC):\r\n- <del> Normally the keylog callback will just write to file. Would it not be better if the callback (implemented in #1646) automatically adds the newline as well? This would save another copy since normally the keylog file entry must be written with one syscall (or else concurrent access might spoil it).\r\n- <del> Is this appropriate use of BIO? Goal is to append at once.","created_at":"2017-02-01T18:20:54Z","updated_at":"2017-02-02T00:23:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f738810785f56bb8f3437b98e71c5d90533eacb2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openssl/openssl/pulls/2343/commits","review_comments_url":"https://api.github.com/repos/openssl/openssl/pulls/2343/comments","review_comment_url":"https://api.github.com/repos/openssl/openssl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openssl/openssl/issues/2343/comments","statuses_url":"https://api.github.com/repos/openssl/openssl/statuses/56c7569dfc6fbd2d9c717c8fe85fa0615b9da779","head":{"label":"Lekensteyn:keylog-apps","ref":"keylog-apps","sha":"56c7569dfc6fbd2d9c717c8fe85fa0615b9da779","user":{"login":"Lekensteyn","id":164530,"avatar_url":"https://avatars.githubusercontent.com/u/164530?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekensteyn","html_url":"https://github.com/Lekensteyn","followers_url":"https://api.github.com/users/Lekensteyn/followers","following_url":"https://api.github.com/users/Lekensteyn/following{/other_user}","gists_url":"https://api.github.com/users/Lekensteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekensteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekensteyn/subscriptions","organizations_url":"https://api.github.com/users/Lekensteyn/orgs","repos_url":"https://api.github.com/users/Lekensteyn/repos","events_url":"https://api.github.com/users/Lekensteyn/events{/privacy}","received_events_url":"https://api.github.com/users/Lekensteyn/received_events","type":"User","site_admin":false},"repo":{"id":68460930,"name":"openssl","full_name":"Lekensteyn/openssl","owner":{"login":"Lekensteyn","id":164530,"avatar_url":"https://avatars.githubusercontent.com/u/164530?v=3","gravatar_id":"","url":"https://api.github.com/users/Lekensteyn","html_url":"https://github.com/Lekensteyn","followers_url":"https://api.github.com/users/Lekensteyn/followers","following_url":"https://api.github.com/users/Lekensteyn/following{/other_user}","gists_url":"https://api.github.com/users/Lekensteyn/gists{/gist_id}","starred_url":"https://api.github.com/users/Lekensteyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lekensteyn/subscriptions","organizations_url":"https://api.github.com/users/Lekensteyn/orgs","repos_url":"https://api.github.com/users/Lekensteyn/repos","events_url":"https://api.github.com/users/Lekensteyn/events{/privacy}","received_events_url":"https://api.github.com/users/Lekensteyn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Lekensteyn/openssl","description":"TLS/SSL and crypto library","fork":true,"url":"https://api.github.com/repos/Lekensteyn/openssl","forks_url":"https://api.github.com/repos/Lekensteyn/openssl/forks","keys_url":"https://api.github.com/repos/Lekensteyn/openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lekensteyn/openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lekensteyn/openssl/teams","hooks_url":"https://api.github.com/repos/Lekensteyn/openssl/hooks","issue_events_url":"https://api.github.com/repos/Lekensteyn/openssl/issues/events{/number}","events_url":"https://api.github.com/repos/Lekensteyn/openssl/events","assignees_url":"https://api.github.com/repos/Lekensteyn/openssl/assignees{/user}","branches_url":"https://api.github.com/repos/Lekensteyn/openssl/branches{/branch}","tags_url":"https://api.github.com/repos/Lekensteyn/openssl/tags","blobs_url":"https://api.github.com/repos/Lekensteyn/openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lekensteyn/openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lekensteyn/openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lekensteyn/openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lekensteyn/openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/Lekensteyn/openssl/languages","stargazers_url":"https://api.github.com/repos/Lekensteyn/openssl/stargazers","contributors_url":"https://api.github.com/repos/Lekensteyn/openssl/contributors","subscribers_url":"https://api.github.com/repos/Lekensteyn/openssl/subscribers","subscription_url":"https://api.github.com/repos/Lekensteyn/openssl/subscription","commits_url":"https://api.github.com/repos/Lekensteyn/openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lekensteyn/openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lekensteyn/openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lekensteyn/openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lekensteyn/openssl/contents/{+path}","compare_url":"https://api.github.com/repos/Lekensteyn/openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lekensteyn/openssl/merges","archive_url":"https://api.github.com/repos/Lekensteyn/openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lekensteyn/openssl/downloads","issues_url":"https://api.github.com/repos/Lekensteyn/openssl/issues{/number}","pulls_url":"https://api.github.com/repos/Lekensteyn/openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/Lekensteyn/openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/Lekensteyn/openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lekensteyn/openssl/labels{/name}","releases_url":"https://api.github.com/repos/Lekensteyn/openssl/releases{/id}","deployments_url":"https://api.github.com/repos/Lekensteyn/openssl/deployments","created_at":"2016-09-17T15:35:16Z","updated_at":"2017-02-01T18:17:05Z","pushed_at":"2017-02-02T00:19:33Z","git_url":"git://github.com/Lekensteyn/openssl.git","ssh_url":"git@github.com:Lekensteyn/openssl.git","clone_url":"https://github.com/Lekensteyn/openssl.git","svn_url":"https://github.com/Lekensteyn/openssl","homepage":"https://www.openssl.org","size":113639,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"openssl:master","ref":"master","sha":"3f5616d734a92fdf99ab827f21e5b6cab85e7194","user":{"login":"openssl","id":3279138,"avatar_url":"https://avatars.githubusercontent.com/u/3279138?v=3","gravatar_id":"","url":"https://api.github.com/users/openssl","html_url":"https://github.com/openssl","followers_url":"https://api.github.com/users/openssl/followers","following_url":"https://api.github.com/users/openssl/following{/other_user}","gists_url":"https://api.github.com/users/openssl/gists{/gist_id}","starred_url":"https://api.github.com/users/openssl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openssl/subscriptions","organizations_url":"https://api.github.com/users/openssl/orgs","repos_url":"https://api.github.com/users/openssl/repos","events_url":"https://api.github.com/users/openssl/events{/privacy}","received_events_url":"https://api.github.com/users/openssl/received_events","type":"Organization","site_admin":false},"repo":{"id":7634677,"name":"openssl","full_name":"openssl/openssl","owner":{"login":"openssl","id":3279138,"avatar_url":"https://avatars.githubusercontent.com/u/3279138?v=3","gravatar_id":"","url":"https://api.github.com/users/openssl","html_url":"https://github.com/openssl","followers_url":"https://api.github.com/users/openssl/followers","following_url":"https://api.github.com/users/openssl/following{/other_user}","gists_url":"https://api.github.com/users/openssl/gists{/gist_id}","starred_url":"https://api.github.com/users/openssl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openssl/subscriptions","organizations_url":"https://api.github.com/users/openssl/orgs","repos_url":"https://api.github.com/users/openssl/repos","events_url":"https://api.github.com/users/openssl/events{/privacy}","received_events_url":"https://api.github.com/users/openssl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openssl/openssl","description":"TLS/SSL and crypto library","fork":false,"url":"https://api.github.com/repos/openssl/openssl","forks_url":"https://api.github.com/repos/openssl/openssl/forks","keys_url":"https://api.github.com/repos/openssl/openssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openssl/openssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openssl/openssl/teams","hooks_url":"https://api.github.com/repos/openssl/openssl/hooks","issue_events_url":"https://api.github.com/repos/openssl/openssl/issues/events{/number}","events_url":"https://api.github.com/repos/openssl/openssl/events","assignees_url":"https://api.github.com/repos/openssl/openssl/assignees{/user}","branches_url":"https://api.github.com/repos/openssl/openssl/branches{/branch}","tags_url":"https://api.github.com/repos/openssl/openssl/tags","blobs_url":"https://api.github.com/repos/openssl/openssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openssl/openssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openssl/openssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/openssl/openssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openssl/openssl/statuses/{sha}","languages_url":"https://api.github.com/repos/openssl/openssl/languages","stargazers_url":"https://api.github.com/repos/openssl/openssl/stargazers","contributors_url":"https://api.github.com/repos/openssl/openssl/contributors","subscribers_url":"https://api.github.com/repos/openssl/openssl/subscribers","subscription_url":"https://api.github.com/repos/openssl/openssl/subscription","commits_url":"https://api.github.com/repos/openssl/openssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/openssl/openssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/openssl/openssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/openssl/openssl/issues/comments{/number}","contents_url":"https://api.github.com/repos/openssl/openssl/contents/{+path}","compare_url":"https://api.github.com/repos/openssl/openssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openssl/openssl/merges","archive_url":"https://api.github.com/repos/openssl/openssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openssl/openssl/downloads","issues_url":"https://api.github.com/repos/openssl/openssl/issues{/number}","pulls_url":"https://api.github.com/repos/openssl/openssl/pulls{/number}","milestones_url":"https://api.github.com/repos/openssl/openssl/milestones{/number}","notifications_url":"https://api.github.com/repos/openssl/openssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openssl/openssl/labels{/name}","releases_url":"https://api.github.com/repos/openssl/openssl/releases{/id}","deployments_url":"https://api.github.com/repos/openssl/openssl/deployments","created_at":"2013-01-15T22:34:48Z","updated_at":"2017-02-02T00:06:28Z","pushed_at":"2017-02-02T00:19:36Z","git_url":"git://github.com/openssl/openssl.git","ssh_url":"git@github.com:openssl/openssl.git","clone_url":"https://github.com/openssl/openssl.git","svn_url":"https://github.com/openssl/openssl","homepage":"https://www.openssl.org","size":115714,"stargazers_count":4065,"watchers_count":4065,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2170,"mirror_url":null,"open_issues_count":282,"forks":2170,"open_issues":282,"watchers":4065,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openssl/openssl/pulls/2343"},"html":{"href":"https://github.com/openssl/openssl/pull/2343"},"issue":{"href":"https://api.github.com/repos/openssl/openssl/issues/2343"},"comments":{"href":"https://api.github.com/repos/openssl/openssl/issues/2343/comments"},"review_comments":{"href":"https://api.github.com/repos/openssl/openssl/pulls/2343/comments"},"review_comment":{"href":"https://api.github.com/repos/openssl/openssl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openssl/openssl/pulls/2343/commits"},"statuses":{"href":"https://api.github.com/repos/openssl/openssl/statuses/56c7569dfc6fbd2d9c717c8fe85fa0615b9da779"}}}}
{"actor":{"display_login":"levitte"}}