Skip to content

Commit 94af01c

Browse files
committed
Unused self-signed SSL utility
1 parent aaef14a commit 94af01c

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ yarn-error.log*
1212
.npm
1313
.eslintcache
1414
*.env
15+
cert/

index.js

+9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { connect } from "./actioncable.js";
99
import EventEmitter from "node:events";
1010
import { Page, RootBody, Room, EditNoteForm } from "./html.js";
1111

12+
import fs from "node:fs";
1213
const emitter = new EventEmitter();
14+
const CERT_DIR = `./cert`;
1315

1416
const app = express();
1517
const port = process.env.PORT || 3001;
@@ -109,6 +111,13 @@ const baseURL =
109111
process.env.NODE_ENV === "production"
110112
? `https://${baseDomain}`
111113
: `http://${baseDomain}`;
114+
const sslConfig =
115+
process.env.NODE_ENV === "production"
116+
? {}
117+
: {
118+
key: fs.readFileSync(`${CERT_DIR}/server.key`),
119+
cert: fs.readFileSync(`${CERT_DIR}/server.cert`),
120+
};
112121

113122
const authorizeEndpoint = "https://recurse.com/oauth/authorize";
114123
// TODO P.B. found this required `www` though authorize doesn't.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "node --env-file=config.env index.js"
8+
"start": "node --env-file=config.env index.js",
9+
"generate-cert": "sh ./scripts/generate-cert.sh"
910
},
1011
"type": "module",
1112
"keywords": [],

scripts/generate-cert.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
openssl req -nodes -new -x509 \
3+
-keyout ./cert/server.key \
4+
-out ./cert/server.cert \
5+
-subj "/C=US/ST=State/L=City/O=company/OU=Com/CN=www.testserver.local"

0 commit comments

Comments
 (0)