{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/create-react-app/pulls/comments/239772791","pull_request_review_id":182648084,"id":239772791,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzOTc3Mjc5MQ==","diff_hunk":"@@ -8,16 +8,64 @@\n // @remove-on-eject-end\n 'use strict';\n \n+const fs = require('fs');\n+const path = require('path');\n+const chalk = require('chalk');\n+const crypto = require('crypto');\n const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');\n const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');\n const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');\n const ignoredFiles = require('react-dev-utils/ignoredFiles');\n const paths = require('./paths');\n-const fs = require('fs');\n \n-const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';\n const host = process.env.HOST || '0.0.0.0';\n \n+// Get the https config\n+// Return cert files if provided in env, otherwise just true or false\n+function httpsConfig() {\n+  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;\n+  const https = HTTPS === 'true';\n+\n+  if (https && SSL_CRT_FILE && SSL_KEY_FILE) {\n+    const cwd = process.cwd();\n+    const crtFile = path.resolve(cwd, SSL_CRT_FILE);\n+    const keyFile = path.resolve(cwd, SSL_KEY_FILE);\n+    if (!fs.existsSync(crtFile)) {\n+      throw new Error(\n+        `You specified ${chalk.cyan(\n+          'SSL_CRT_FILE'\n+        )} in your env, but the file \"${chalk.yellow(crtFile)}\" doesn't exist.`\n+      );\n+    }\n+    if (!fs.existsSync(keyFile)) {\n+      throw new Error(\n+        `You specified ${chalk.cyan(\n+          'SSL_KEY_FILE'\n+        )} in your env, but the file \"${chalk.yellow(keyFile)}\" doesn't exist.`\n+      );\n+    }\n+    const config = {\n+      key: fs.readFileSync(keyFile),\n+      cert: fs.readFileSync(crtFile),\n+    };\n+    try {\n+      crypto.publicEncrypt(config.cert, new Buffer(''));","path":"packages/react-scripts/config/webpackDevServer.config.js","position":47,"original_position":47,"commit_id":"d099aa54c4080c2cee54a3719387b83fc877f90d","original_commit_id":"d099aa54c4080c2cee54a3719387b83fc877f90d","user":{"login":"alexbrazier","id":5689874,"node_id":"MDQ6VXNlcjU2ODk4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5689874?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbrazier","html_url":"https://github.com/alexbrazier","followers_url":"https://api.github.com/users/alexbrazier/followers","following_url":"https://api.github.com/users/alexbrazier/following{/other_user}","gists_url":"https://api.github.com/users/alexbrazier/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbrazier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbrazier/subscriptions","organizations_url":"https://api.github.com/users/alexbrazier/orgs","repos_url":"https://api.github.com/users/alexbrazier/repos","events_url":"https://api.github.com/users/alexbrazier/events{/privacy}","received_events_url":"https://api.github.com/users/alexbrazier/received_events","type":"User","site_admin":false},"body":"@joggienl Thanks for reviewing. The reason for this is to try and stay consistent with create react app being easy to use and debug. This check, and the one below is to validate the certs passed in. If they are invalid it logs an easy to understand error. Without this the standard error message is some random text related to the crypto package, and it isn't clear what went wrong.","created_at":"2018-12-07T11:11:53Z","updated_at":"2018-12-07T11:11:54Z","html_url":"https://github.com/facebook/create-react-app/pull/5845#discussion_r239772791","pull_request_url":"https://api.github.com/repos/facebook/create-react-app/pulls/5845","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/comments/239772791"},"html":{"href":"https://github.com/facebook/create-react-app/pull/5845#discussion_r239772791"},"pull_request":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/5845"}},"in_reply_to_id":239753795},"pull_request":{"url":"https://api.github.com/repos/facebook/create-react-app/pulls/5845","id":231750065,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxNzUwMDY1","html_url":"https://github.com/facebook/create-react-app/pull/5845","diff_url":"https://github.com/facebook/create-react-app/pull/5845.diff","patch_url":"https://github.com/facebook/create-react-app/pull/5845.patch","issue_url":"https://api.github.com/repos/facebook/create-react-app/issues/5845","number":5845,"state":"open","locked":false,"title":"Add option to provide custom ssl certificates during development","user":{"login":"alexbrazier","id":5689874,"node_id":"MDQ6VXNlcjU2ODk4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5689874?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbrazier","html_url":"https://github.com/alexbrazier","followers_url":"https://api.github.com/users/alexbrazier/followers","following_url":"https://api.github.com/users/alexbrazier/following{/other_user}","gists_url":"https://api.github.com/users/alexbrazier/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbrazier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbrazier/subscriptions","organizations_url":"https://api.github.com/users/alexbrazier/orgs","repos_url":"https://api.github.com/users/alexbrazier/repos","events_url":"https://api.github.com/users/alexbrazier/events{/privacy}","received_events_url":"https://api.github.com/users/alexbrazier/received_events","type":"User","site_admin":false},"body":"Closes: #4050 #3603 #3441 #1411\r\n\r\nThis PR adds the option to provide a custom SSL certificate and key using the `SSL_CRT_FILE` and `SSL_KEY_FILE` env vars.\r\n\r\nThe webpack dev server already accepts certificates if you provide them, so this just reads the files and passes them in.\r\n\r\nAs an extra check so there is no confusion when an error occurs, it will verify the files exist and that they are valid before passing them into webpack.\r\n\r\nYou can pass in relative paths `../cert.crt`, `cert.crt` etc, or full paths `/Users/test/cert.crt`\r\n\r\n### Testing\r\n- [x] Tested using `yarn start` and `yarn create-react-app my-app`\r\n- [x] Tested with `.env` file\r\n- [x] Tested with exported envs and inline envs\r\n- [x] Tested without `HTTPS` flag - (same behaviour as before)\r\n- [x] Tested with `HTTPS` flag and without new flags - (same behaviour as before)\r\n- [x] Tested with invalid path (see error below)\r\n- [x] Tested with invalid cert and key (see error below)\r\n- [x] Tested with valid custom cert and verified the dev server was using it\r\n\r\n### Invalid config errors\r\n#### Doesn't exist\r\n![image](https://user-images.githubusercontent.com/5689874/48665469-bd86d100-eaa6-11e8-8718-98f6a3630194.png)\r\n\r\n#### Invalid cert file\r\n![image](https://user-images.githubusercontent.com/5689874/48665447-62ed7500-eaa6-11e8-9dcc-a362389d8a7c.png)\r\n\r\n","created_at":"2018-11-17T20:33:53Z","updated_at":"2018-12-07T11:11:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e148a8efcaf5db76793f9c4ef41cf7707313ecde","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":409579052,"node_id":"MDU6TGFiZWw0MDk1NzkwNTI=","url":"https://api.github.com/repos/facebook/create-react-app/labels/CLA%20Signed","name":"CLA Signed","color":"009900","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/create-react-app/pulls/5845/commits","review_comments_url":"https://api.github.com/repos/facebook/create-react-app/pulls/5845/comments","review_comment_url":"https://api.github.com/repos/facebook/create-react-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/create-react-app/issues/5845/comments","statuses_url":"https://api.github.com/repos/facebook/create-react-app/statuses/d099aa54c4080c2cee54a3719387b83fc877f90d","head":{"label":"alexbrazier:feature/custom-ssl","ref":"feature/custom-ssl","sha":"d099aa54c4080c2cee54a3719387b83fc877f90d","user":{"login":"alexbrazier","id":5689874,"node_id":"MDQ6VXNlcjU2ODk4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5689874?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbrazier","html_url":"https://github.com/alexbrazier","followers_url":"https://api.github.com/users/alexbrazier/followers","following_url":"https://api.github.com/users/alexbrazier/following{/other_user}","gists_url":"https://api.github.com/users/alexbrazier/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbrazier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbrazier/subscriptions","organizations_url":"https://api.github.com/users/alexbrazier/orgs","repos_url":"https://api.github.com/users/alexbrazier/repos","events_url":"https://api.github.com/users/alexbrazier/events{/privacy}","received_events_url":"https://api.github.com/users/alexbrazier/received_events","type":"User","site_admin":false},"repo":{"id":137611498,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc2MTE0OTg=","name":"create-react-app","full_name":"alexbrazier/create-react-app","private":false,"owner":{"login":"alexbrazier","id":5689874,"node_id":"MDQ6VXNlcjU2ODk4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5689874?v=4","gravatar_id":"","url":"https://api.github.com/users/alexbrazier","html_url":"https://github.com/alexbrazier","followers_url":"https://api.github.com/users/alexbrazier/followers","following_url":"https://api.github.com/users/alexbrazier/following{/other_user}","gists_url":"https://api.github.com/users/alexbrazier/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbrazier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbrazier/subscriptions","organizations_url":"https://api.github.com/users/alexbrazier/orgs","repos_url":"https://api.github.com/users/alexbrazier/repos","events_url":"https://api.github.com/users/alexbrazier/events{/privacy}","received_events_url":"https://api.github.com/users/alexbrazier/received_events","type":"User","site_admin":false},"html_url":"https://github.com/alexbrazier/create-react-app","description":"Create React apps with no build configuration.","fork":true,"url":"https://api.github.com/repos/alexbrazier/create-react-app","forks_url":"https://api.github.com/repos/alexbrazier/create-react-app/forks","keys_url":"https://api.github.com/repos/alexbrazier/create-react-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexbrazier/create-react-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexbrazier/create-react-app/teams","hooks_url":"https://api.github.com/repos/alexbrazier/create-react-app/hooks","issue_events_url":"https://api.github.com/repos/alexbrazier/create-react-app/issues/events{/number}","events_url":"https://api.github.com/repos/alexbrazier/create-react-app/events","assignees_url":"https://api.github.com/repos/alexbrazier/create-react-app/assignees{/user}","branches_url":"https://api.github.com/repos/alexbrazier/create-react-app/branches{/branch}","tags_url":"https://api.github.com/repos/alexbrazier/create-react-app/tags","blobs_url":"https://api.github.com/repos/alexbrazier/create-react-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexbrazier/create-react-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexbrazier/create-react-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexbrazier/create-react-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexbrazier/create-react-app/statuses/{sha}","languages_url":"https://api.github.com/repos/alexbrazier/create-react-app/languages","stargazers_url":"https://api.github.com/repos/alexbrazier/create-react-app/stargazers","contributors_url":"https://api.github.com/repos/alexbrazier/create-react-app/contributors","subscribers_url":"https://api.github.com/repos/alexbrazier/create-react-app/subscribers","subscription_url":"https://api.github.com/repos/alexbrazier/create-react-app/subscription","commits_url":"https://api.github.com/repos/alexbrazier/create-react-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexbrazier/create-react-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexbrazier/create-react-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexbrazier/create-react-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexbrazier/create-react-app/contents/{+path}","compare_url":"https://api.github.com/repos/alexbrazier/create-react-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexbrazier/create-react-app/merges","archive_url":"https://api.github.com/repos/alexbrazier/create-react-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexbrazier/create-react-app/downloads","issues_url":"https://api.github.com/repos/alexbrazier/create-react-app/issues{/number}","pulls_url":"https://api.github.com/repos/alexbrazier/create-react-app/pulls{/number}","milestones_url":"https://api.github.com/repos/alexbrazier/create-react-app/milestones{/number}","notifications_url":"https://api.github.com/repos/alexbrazier/create-react-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexbrazier/create-react-app/labels{/name}","releases_url":"https://api.github.com/repos/alexbrazier/create-react-app/releases{/id}","deployments_url":"https://api.github.com/repos/alexbrazier/create-react-app/deployments","created_at":"2018-06-16T21:28:42Z","updated_at":"2018-06-16T21:28:47Z","pushed_at":"2018-11-17T20:05:31Z","git_url":"git://github.com/alexbrazier/create-react-app.git","ssh_url":"git@github.com:alexbrazier/create-react-app.git","clone_url":"https://github.com/alexbrazier/create-react-app.git","svn_url":"https://github.com/alexbrazier/create-react-app","homepage":null,"size":8004,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"next"}},"base":{"label":"facebook:master","ref":"master","sha":"7e25df150de3c781430979effffa41cec0ba929f","user":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":63537249,"node_id":"MDEwOlJlcG9zaXRvcnk2MzUzNzI0OQ==","name":"create-react-app","full_name":"facebook/create-react-app","private":false,"owner":{"login":"facebook","id":69631,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NjMx","avatar_url":"https://avatars3.githubusercontent.com/u/69631?v=4","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/facebook/create-react-app","description":"Set up a modern web app by running one command.","fork":false,"url":"https://api.github.com/repos/facebook/create-react-app","forks_url":"https://api.github.com/repos/facebook/create-react-app/forks","keys_url":"https://api.github.com/repos/facebook/create-react-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/create-react-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/create-react-app/teams","hooks_url":"https://api.github.com/repos/facebook/create-react-app/hooks","issue_events_url":"https://api.github.com/repos/facebook/create-react-app/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/create-react-app/events","assignees_url":"https://api.github.com/repos/facebook/create-react-app/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/create-react-app/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/create-react-app/tags","blobs_url":"https://api.github.com/repos/facebook/create-react-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/create-react-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/create-react-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/create-react-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/create-react-app/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/create-react-app/languages","stargazers_url":"https://api.github.com/repos/facebook/create-react-app/stargazers","contributors_url":"https://api.github.com/repos/facebook/create-react-app/contributors","subscribers_url":"https://api.github.com/repos/facebook/create-react-app/subscribers","subscription_url":"https://api.github.com/repos/facebook/create-react-app/subscription","commits_url":"https://api.github.com/repos/facebook/create-react-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/create-react-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/create-react-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/create-react-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/create-react-app/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/create-react-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/create-react-app/merges","archive_url":"https://api.github.com/repos/facebook/create-react-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/create-react-app/downloads","issues_url":"https://api.github.com/repos/facebook/create-react-app/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/create-react-app/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/create-react-app/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/create-react-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/create-react-app/labels{/name}","releases_url":"https://api.github.com/repos/facebook/create-react-app/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/create-react-app/deployments","created_at":"2016-07-17T14:55:11Z","updated_at":"2018-12-07T10:23:19Z","pushed_at":"2018-12-07T00:36:42Z","git_url":"git://github.com/facebook/create-react-app.git","ssh_url":"git@github.com:facebook/create-react-app.git","clone_url":"https://github.com/facebook/create-react-app.git","svn_url":"https://github.com/facebook/create-react-app","homepage":"https://facebook.github.io/create-react-app/","size":8202,"stargazers_count":60252,"watchers_count":60252,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":13095,"mirror_url":null,"archived":false,"open_issues_count":367,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":13095,"open_issues":367,"watchers":60252,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/5845"},"html":{"href":"https://github.com/facebook/create-react-app/pull/5845"},"issue":{"href":"https://api.github.com/repos/facebook/create-react-app/issues/5845"},"comments":{"href":"https://api.github.com/repos/facebook/create-react-app/issues/5845/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/5845/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/create-react-app/pulls/5845/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/create-react-app/statuses/d099aa54c4080c2cee54a3719387b83fc877f90d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"alexbrazier"}}