{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/110683320","pull_request_review_id":31871440,"id":110683320,"diff_hunk":"@@ -228,25 +295,51 @@ void save(Path configDir) throws Exception {\n \n     @Override\n     public Set<String> getSettingNames() {\n-        return settingNames;\n+        return settingTypes.keySet();\n     }\n \n     // TODO: make settings accessible only to code that registered the setting\n-    /** Retrieve a string setting. The {@link SecureString} should be closed once it is used. */\n     @Override\n     public SecureString getString(String setting) throws GeneralSecurityException {\n         KeyStore.Entry entry = keystore.get().getEntry(setting, keystorePassword.get());\n-        if (entry instanceof KeyStore.SecretKeyEntry == false) {\n+        if (settingTypes.get(setting) != KeyType.STRING ||\n+            entry instanceof KeyStore.SecretKeyEntry == false) {\n             throw new IllegalStateException(\"Secret setting \" + setting + \" is not a string\");\n         }\n         // TODO: only allow getting a setting once?\n         KeyStore.SecretKeyEntry secretKeyEntry = (KeyStore.SecretKeyEntry) entry;\n-        PBEKeySpec keySpec = (PBEKeySpec) secretFactory.getKeySpec(secretKeyEntry.getSecretKey(), PBEKeySpec.class);\n+        PBEKeySpec keySpec = (PBEKeySpec) stringFactory.getKeySpec(secretKeyEntry.getSecretKey(), PBEKeySpec.class);\n         SecureString value = new SecureString(keySpec.getPassword());\n         keySpec.clearPassword();\n         return value;\n     }\n \n+    @Override\n+    public InputStream getFile(String setting) throws GeneralSecurityException {\n+        KeyStore.Entry entry = keystore.get().getEntry(setting, keystorePassword.get());\n+        if (settingTypes.get(setting) != KeyType.FILE ||\n+            entry instanceof KeyStore.SecretKeyEntry == false) {\n+            throw new IllegalStateException(\"Secret setting \" + setting + \" is not a file\");\n+        }\n+        KeyStore.SecretKeyEntry secretKeyEntry = (KeyStore.SecretKeyEntry) entry;\n+        PBEKeySpec keySpec = (PBEKeySpec) fileFactory.getKeySpec(secretKeyEntry.getSecretKey(), PBEKeySpec.class);\n+        // The PBE keyspec gives us chars, we first convert to bytes, then decode base64 inline.\n+        char[] chars = keySpec.getPassword();","path":"core/src/main/java/org/elasticsearch/common/settings/KeyStoreWrapper.java","position":248,"original_position":248,"commit_id":"16e88c499e26d26010668d169d596b6625c42db1","original_commit_id":"16e88c499e26d26010668d169d596b6625c42db1","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars3.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"so these are all 1 byte chars here in the password?","created_at":"2017-04-10T15:15:02Z","updated_at":"2017-04-10T15:17:15Z","html_url":"https://github.com/elastic/elasticsearch/pull/24001#discussion_r110683320","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/110683320"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/24001#discussion_r110683320"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001","id":115030662,"html_url":"https://github.com/elastic/elasticsearch/pull/24001","diff_url":"https://github.com/elastic/elasticsearch/pull/24001.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/24001.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/24001","number":24001,"state":"open","locked":false,"title":"Settings: Add secure file setting to keystore","user":{"login":"rjernst","id":289412,"avatar_url":"https://avatars0.githubusercontent.com/u/289412?v=3","gravatar_id":"","url":"https://api.github.com/users/rjernst","html_url":"https://github.com/rjernst","followers_url":"https://api.github.com/users/rjernst/followers","following_url":"https://api.github.com/users/rjernst/following{/other_user}","gists_url":"https://api.github.com/users/rjernst/gists{/gist_id}","starred_url":"https://api.github.com/users/rjernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjernst/subscriptions","organizations_url":"https://api.github.com/users/rjernst/orgs","repos_url":"https://api.github.com/users/rjernst/repos","events_url":"https://api.github.com/users/rjernst/events{/privacy}","received_events_url":"https://api.github.com/users/rjernst/received_events","type":"User","site_admin":false},"body":"Some systems like GCE rely on a plaintext file containing credentials.\r\nRather than extract the information out of that credentials file and\r\nstore each peace individually in the keystore, it is cleaner to just\r\nstore the entire file.\r\n\r\nThis commit adds support to the keystore wrapper for secure file\r\nsettings. These are settings that contain an entire file that would\r\nnormally be stored on the local filesystem. Retrieving the file returns\r\nan input stream to the file contents. This also adds a `add-file`\r\ncommand to the keystore cli.","created_at":"2017-04-10T06:01:31Z","updated_at":"2017-04-10T15:17:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"676d13ad025387ed2c4b6b7cc00116f482a10c1d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/24001/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/16e88c499e26d26010668d169d596b6625c42db1","head":{"label":"rjernst:keystore10","ref":"keystore10","sha":"16e88c499e26d26010668d169d596b6625c42db1","user":{"login":"rjernst","id":289412,"avatar_url":"https://avatars0.githubusercontent.com/u/289412?v=3","gravatar_id":"","url":"https://api.github.com/users/rjernst","html_url":"https://github.com/rjernst","followers_url":"https://api.github.com/users/rjernst/followers","following_url":"https://api.github.com/users/rjernst/following{/other_user}","gists_url":"https://api.github.com/users/rjernst/gists{/gist_id}","starred_url":"https://api.github.com/users/rjernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjernst/subscriptions","organizations_url":"https://api.github.com/users/rjernst/orgs","repos_url":"https://api.github.com/users/rjernst/repos","events_url":"https://api.github.com/users/rjernst/events{/privacy}","received_events_url":"https://api.github.com/users/rjernst/received_events","type":"User","site_admin":false},"repo":{"id":21088403,"name":"elasticsearch","full_name":"rjernst/elasticsearch","owner":{"login":"rjernst","id":289412,"avatar_url":"https://avatars0.githubusercontent.com/u/289412?v=3","gravatar_id":"","url":"https://api.github.com/users/rjernst","html_url":"https://github.com/rjernst","followers_url":"https://api.github.com/users/rjernst/followers","following_url":"https://api.github.com/users/rjernst/following{/other_user}","gists_url":"https://api.github.com/users/rjernst/gists{/gist_id}","starred_url":"https://api.github.com/users/rjernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjernst/subscriptions","organizations_url":"https://api.github.com/users/rjernst/orgs","repos_url":"https://api.github.com/users/rjernst/repos","events_url":"https://api.github.com/users/rjernst/events{/privacy}","received_events_url":"https://api.github.com/users/rjernst/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rjernst/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/rjernst/elasticsearch","forks_url":"https://api.github.com/repos/rjernst/elasticsearch/forks","keys_url":"https://api.github.com/repos/rjernst/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rjernst/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rjernst/elasticsearch/teams","hooks_url":"https://api.github.com/repos/rjernst/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/rjernst/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/rjernst/elasticsearch/events","assignees_url":"https://api.github.com/repos/rjernst/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/rjernst/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/rjernst/elasticsearch/tags","blobs_url":"https://api.github.com/repos/rjernst/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rjernst/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rjernst/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/rjernst/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rjernst/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/rjernst/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/rjernst/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/rjernst/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/rjernst/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/rjernst/elasticsearch/subscription","commits_url":"https://api.github.com/repos/rjernst/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/rjernst/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/rjernst/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/rjernst/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/rjernst/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/rjernst/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rjernst/elasticsearch/merges","archive_url":"https://api.github.com/repos/rjernst/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rjernst/elasticsearch/downloads","issues_url":"https://api.github.com/repos/rjernst/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/rjernst/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/rjernst/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/rjernst/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rjernst/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/rjernst/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/rjernst/elasticsearch/deployments","created_at":"2014-06-22T07:43:32Z","updated_at":"2014-10-12T08:10:41Z","pushed_at":"2017-04-10T06:00:19Z","git_url":"git://github.com/rjernst/elasticsearch.git","ssh_url":"git@github.com:rjernst/elasticsearch.git","clone_url":"https://github.com/rjernst/elasticsearch.git","svn_url":"https://github.com/rjernst/elasticsearch","homepage":"http://elasticsearch.org","size":285377,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"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":"elastic:master","ref":"master","sha":"b636ca79d579dbef3965b578fa8253aa6189e263","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars3.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars3.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2017-04-10T14:43:44Z","pushed_at":"2017-04-10T15:09:52Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":333863,"stargazers_count":21936,"watchers_count":21936,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7277,"mirror_url":null,"open_issues_count":1344,"forks":7277,"open_issues":1344,"watchers":21936,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/24001"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/24001"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/24001/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/24001/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/16e88c499e26d26010668d169d596b6625c42db1"}}}}
{"actor":{"display_login":"s1monw"}}