-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jsonjoy-com/https
TLS/HTTPS support
- Loading branch information
Showing
11 changed files
with
222 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Run: npx ts-node src/__demos__/json-crdt-server/main-http1-tls.ts | ||
// curl https://localhost/rx --insecure -d '[1,1,"util.ping"]' | ||
|
||
import type * as tls from 'tls'; | ||
import * as fs from 'fs'; | ||
import {createCaller, createServices} from './routes'; | ||
import {RpcServer} from '../../server/http1/RpcServer'; | ||
|
||
export type JsonJoyDemoRpcCaller = ReturnType<typeof createCaller>['caller']; | ||
|
||
const main = async () => { | ||
const secureContext = async (): Promise<tls.SecureContextOptions> => { | ||
return { | ||
key: await fs.promises.readFile(__dirname + '/../../__tests__/certs/server.key'), | ||
cert: await fs.promises.readFile(__dirname + '/../../__tests__/certs/server.crt'), | ||
}; | ||
}; | ||
|
||
const services = await createServices(); | ||
const server = await RpcServer.startWithDefaults({ | ||
create: { | ||
tls: true, | ||
secureContext, | ||
secureContextRefreshInterval: 1000 * 60 * 60 * 24, | ||
}, | ||
port: +(process.env.PORT || 443), | ||
caller: createCaller(services).caller, | ||
logger: console, | ||
}); | ||
|
||
// tslint:disable-next-line:no-console | ||
console.log(server + ''); | ||
}; | ||
|
||
// tslint:disable-next-line no-console | ||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDazCCAlOgAwIBAgIUTCuaouku5UxROTTWDaMZ02A+rMwwDQYJKoZIhvcNAQEL | ||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM | ||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDEwMDcwNzM1MDhaFw0yNTEw | ||
MDcwNzM1MDhaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw | ||
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB | ||
AQUAA4IBDwAwggEKAoIBAQCibOXoqQTSAvjVFNOZOt6MT9PK1HqTJjknITMPYsrh | ||
8BZemAAV9pEImeNNBGqScO4oUHX3ZmqcGn6PyTtIWGClXkuVAlghEMNuHqunqRFl | ||
isYaNMsvlmRxFaWVzRq7iN8S+zX0ongtLCUDRexkZmBzM6+aBszifTwMd7oryQhj | ||
9adBROw8yl1yZF33T+a6khQwJ96S5NL/cBbD6aHYH/2DbODN1ru6CGHi0f6b+kUW | ||
1t5xsuc2K+DAWNfmEDQ47EMxS8OYhh2Y/0V/YCIuOIU1tlVL78XjOBmjssPpNFfg | ||
86Uqcfyx0+naQWLF/2r4uUTT3nNhWofM0pXA7DxuMawXAgMBAAGjUzBRMB0GA1Ud | ||
DgQWBBRBA4dUj3VDyFhGSvtIMFkfxMxkOjAfBgNVHSMEGDAWgBRBA4dUj3VDyFhG | ||
SvtIMFkfxMxkOjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBi | ||
UTc+mRjoSKjpxYgoEFF6MDm24IrZ9b0NSFNHrM9hbbbErJgQ3UJkUAjXweRxvWPw | ||
gL8HLGLDjsUg/h4D33xndmoXPvmQAuiBFaujWqOeZ7mcwbLNVkDNZzgdo8ggfXkn | ||
e64u37aSoUV+XdyeyJyRBHpVfdTPeptN/KhdijjL0uWiw48A7sDZsgz0SZKSxdF3 | ||
TVQA2W1dGJ0yAEqnbIc3f2HbRg6PXs2jyQ0pdWjQlaARJ3KV433V2T0ecKXQaXoL | ||
B8cvXrfn4dEkHd4tBZqB5Z/bVxj14g5jtq5f/FWupZwWCvP28vDe0ZJw/5/7R10R | ||
1S3XB1fJh48m0c7k9gn3 | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCibOXoqQTSAvjV | ||
FNOZOt6MT9PK1HqTJjknITMPYsrh8BZemAAV9pEImeNNBGqScO4oUHX3ZmqcGn6P | ||
yTtIWGClXkuVAlghEMNuHqunqRFlisYaNMsvlmRxFaWVzRq7iN8S+zX0ongtLCUD | ||
RexkZmBzM6+aBszifTwMd7oryQhj9adBROw8yl1yZF33T+a6khQwJ96S5NL/cBbD | ||
6aHYH/2DbODN1ru6CGHi0f6b+kUW1t5xsuc2K+DAWNfmEDQ47EMxS8OYhh2Y/0V/ | ||
YCIuOIU1tlVL78XjOBmjssPpNFfg86Uqcfyx0+naQWLF/2r4uUTT3nNhWofM0pXA | ||
7DxuMawXAgMBAAECggEAJwQOk/0prcLN/+1BSND1zXGNd+7jRL6NQwN8DumVv4Ea | ||
9nz/pEb2nsDMc18otGWRJ7jwJU4CNN4+YY6egWnNSVvlvvTxs3uh3i1a4WrAxYn4 | ||
vSnKVvOCzBE9lcbPcZXWs+oJE2sFgCBXAbrFpnZbG8EiINcaVxtrFbmazFK9g7kI | ||
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FeCP0j7UFQEx | ||
Dn97qAEU6vqvMz8vUBXTxA== | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2AAEBC5B9C0D89E6BF42BF00A11B7178A5BDD49A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDWjCCAkKgAwIBAgIUKq68W5wNiea/Qr8AoRtxeKW91JowDQYJKoZIhvcNAQEL | ||
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM | ||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yNDEwMDcwOTA2MjNaFw0yNTEw | ||
MDcwOTA2MjNaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw | ||
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB | ||
AQUAA4IBDwAwggEKAoIBAQDHeHPg8Z+3WPdsoV3Io7ZxEAbAiYPm30vq9I6u6uHY | ||
c2BK/sYAEolQ6a1KMGXeElEtav/msJ1sAr5AX62QiMIie1CV0HN8bUrYeYxM3gdn | ||
f18qW4q1Cxy3o+lZ42QvwJksC0JbsvD7Eg5SW/pD89hxD1ovREnxbNNZkPkaxCcg | ||
YzruILGkCSWpBjYiXeebjxZTam84fauUXLlzjp7ox2xhBLg5fxxd9aPahc2szLeY | ||
7v4pk3wZJ8EU3BJpgkOQrlyLQmZ31/dWDAHxqRteFqt6wGLvBYBwxKvHcWyxoxhI | ||
5AU6c5IWiUn0Sd66dy31X+konEZSPaUchyGsqTTTpkfjAgMBAAGjQjBAMB0GA1Ud | ||
DgQWBBT4zgQm2Katn77dYvHsiT4b/9v8bTAfBgNVHSMEGDAWgBRBA4dUj3VDyFhG | ||
SvtIMFkfxMxkOjANBgkqhkiG9w0BAQsFAAOCAQEAia33i3C2yRjh228e3SOOiECn | ||
kAC7aiZ9Qry/lO241XCz9T/SayRuisq5L1B0vBIKMnuqJw6DX+hrnHPJkx7H5N5a | ||
ISwlCCOjcurIDdI2tZZrYu0CLpAhSpY0/hFWswnNKefOWgmDRpxw4iBLpAAeAv5z | ||
aohmi98JdthOQHWvPvu0APz/r7Nb0GpDXjyU2daBnxkiEvBOxXJ7KiFt336haOrn | ||
EJ3Fbba335rfI9CFqCERHjE/SaJGxrL4z8FRx86HdKbl39ILGr73TyySOh0Tp/iG | ||
FXzN2POaKzFdB0ezHZsWyh5KeW7AlJaw5SvHLFljV+r1vRR9sX4O+tj04u6V4Q== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx | ||
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN | ||
AQEBBQADggEPADCCAQoCggEBAMd4c+Dxn7dY92yhXcijtnEQBsCJg+bfS+r0jq7q | ||
4dhzYEr+xgASiVDprUowZd4SUS1q/+awnWwCvkBfrZCIwiJ7UJXQc3xtSth5jEze | ||
B2d/XypbirULHLej6VnjZC/AmSwLQluy8PsSDlJb+kPz2HEPWi9ESfFs01mQ+RrE | ||
JyBjOu4gsaQJJakGNiJd55uPFlNqbzh9q5RcuXOOnujHbGEEuDl/HF31o9qFzazM | ||
t5ju/imTfBknwRTcEmmCQ5CuXItCZnfX91YMAfGpG14Wq3rAYu8FgHDEq8dxbLGj | ||
GEjkBTpzkhaJSfRJ3rp3LfVf6SicRlI9pRyHIaypNNOmR+MCAwEAAaAAMA0GCSqG | ||
SIb3DQEBCwUAA4IBAQBzZYKoSCgIvpJTF9/vgkdJDpWnVROf5xbUCXym8j80ouOm | ||
Wi8sIgdEqofwlUguPvTD2WLKY40tBHTOEtTtnFYXhHOKAQLduHTrVHzZ3MddcLbI | ||
+9FbDmQKnJtGGUQrzUKfRKPcEwZiXxn3IclPbR/bvZP5F+7brMNOTN/AAfBBAByw | ||
RYhwOiKiMlodDWFHLBdllY5z5o/nlIXMuPrWclUMSZjoERbM3niSF3fhw1j9m4Tl | ||
XJnQq0i7n/7KQSRGweckaP3rJu5yn8SmkxmNAo9Fj0H51tpYEdc2K256QVKTGSr2 | ||
bNCcr60ToRiLUL4vokrCbUyIqAPahVwnWg0Kkux1 | ||
-----END CERTIFICATE REQUEST----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDHeHPg8Z+3WPds | ||
oV3Io7ZxEAbAiYPm30vq9I6u6uHYc2BK/sYAEolQ6a1KMGXeElEtav/msJ1sAr5A | ||
X62QiMIie1CV0HN8bUrYeYxM3gdnf18qW4q1Cxy3o+lZ42QvwJksC0JbsvD7Eg5S | ||
W/pD89hxD1ovREnxbNNZkPkaxCcgYzruILGkCSWpBjYiXeebjxZTam84fauUXLlz | ||
jp7ox2xhBLg5fxxd9aPahc2szLeY7v4pk3wZJ8EU3BJpgkOQrlyLQmZ31/dWDAHx | ||
qRteFqt6wGLvBYBwxKvHcWyxox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WBQdA+7HUhz/Std68GED4pUmNLc773O1OkE8N89oDb4POORciM9Oc3x2EGRM+bhi | ||
rM30S5Fhi7xE4r9aEAh47uxmHR2SUYiFX845q75YiwKBgQDOhMRsDY0IplKj1DzI | ||
DK2AcQzhEpXl3wTbcxs48FJs1pBwYPxfgcNEqaHS3nFqwGufeOY7txzfYD758rSO | ||
f+497Z0gLZ6gqdleUNVGqaRYS5oqEhLIV6/k9zkJiBrlh1wztiVSpjZ8on6YeKp7 | ||
Uy/eYp2ikaeFHMW1VOBx0G6qeg== | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters