-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support SSL for redis (#8488)
* chore: support SSL for redis Signed-off-by: Matt Krick <[email protected]> * fix merge master * support REDIS_PASSWORD Signed-off-by: Matt Krick <[email protected]> * add REDIS_PASSWORD to .env.example Signed-off-by: Matt Krick <[email protected]> * add REDIS_SSL_REJECT_UNAUTHORIZED to .env.example Signed-off-by: Matt Krick <[email protected]> * add REDIS_SSL_DIR to .env.example Signed-off-by: Matt Krick <[email protected]> * getRedisSSL to ts Signed-off-by: Matt Krick <[email protected]> * dockerize * dockerize: empty file to build * dockerize Files inside the folder indicate which certificate they are. The folder must host only certificates for Redis * Removing empty.file * fix: redis TLS under all conditions * dockerize fix: quiet logs * remove old env var Signed-off-by: Matt Krick <[email protected]> * docs: add extra env var docs Signed-off-by: Matt Krick <[email protected]> --------- Signed-off-by: Matt Krick <[email protected]> Co-authored-by: Rafael Romero <[email protected]>
- Loading branch information
1 parent
7f4a8bb
commit 46e35da
Showing
17 changed files
with
270 additions
and
28 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,16 @@ | ||
## Certs | ||
|
||
This directory is the preferred place for TLS certs. | ||
The certs that are checked into version control are self-signed and safe to share. | ||
|
||
### Env Vars | ||
|
||
All env vars should correspond with the vars in the redis instance. | ||
In development, that means vars in .env should match the vars in dev.yml. | ||
Any changes to dev.yml require running `yarn db:start` | ||
|
||
REDIS_PASSWORD: Use this if you'd like our app to connect to redis using a password | ||
REDIS_TLS_CERT_FILE: The cert file used to authorize clients. Not available in GCP | ||
REDIS_TLS_KEY_FILE: The key file used to authorize clients. Not available in GCP | ||
REDIS_TLS_CA_FILE: The CA file that proves our redis instance is who it says it is | ||
REDIS_TLS_REJECT_UNAUTHORIZED: Set to false if you're using a self-signed CA file |
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,58 @@ | ||
#!/bin/bash | ||
|
||
# Generate some test certificates which are used by the regression test suite: | ||
# | ||
# tests/tls/ca.{crt,key} Self signed CA certificate. | ||
# tests/tls/redis.{crt,key} A certificate with no key usage/policy restrictions. | ||
# tests/tls/client.{crt,key} A certificate restricted for SSL client usage. | ||
# tests/tls/server.{crt,key} A certificate restricted for SSL server usage. | ||
# tests/tls/redis.dh DH Params file. | ||
|
||
generate_cert() { | ||
local name=$1 | ||
local cn="$2" | ||
local opts="$3" | ||
|
||
local keyfile=tests/tls/${name}.key | ||
local certfile=tests/tls/${name}.crt | ||
|
||
[ -f $keyfile ] || openssl genrsa -out $keyfile 2048 | ||
openssl req \ | ||
-new -sha256 \ | ||
-subj "/O=Redis Test/CN=$cn" \ | ||
-key $keyfile | \ | ||
openssl x509 \ | ||
-req -sha256 \ | ||
-CA tests/tls/ca.crt \ | ||
-CAkey tests/tls/ca.key \ | ||
-CAserial tests/tls/ca.txt \ | ||
-CAcreateserial \ | ||
-days 365 \ | ||
$opts \ | ||
-out $certfile | ||
} | ||
|
||
mkdir -p tests/tls | ||
[ -f tests/tls/ca.key ] || openssl genrsa -out tests/tls/ca.key 4096 | ||
openssl req \ | ||
-x509 -new -nodes -sha256 \ | ||
-key tests/tls/ca.key \ | ||
-days 3650 \ | ||
-subj '/O=Redis Test/CN=Certificate Authority' \ | ||
-out tests/tls/ca.crt | ||
|
||
cat > tests/tls/openssl.cnf <<_END_ | ||
[ server_cert ] | ||
keyUsage = digitalSignature, keyEncipherment | ||
nsCertType = server | ||
[ client_cert ] | ||
keyUsage = digitalSignature, keyEncipherment | ||
nsCertType = client | ||
_END_ | ||
|
||
generate_cert server "Server-only" "-extfile tests/tls/openssl.cnf -extensions server_cert" | ||
generate_cert client "Client-only" "-extfile tests/tls/openssl.cnf -extensions client_cert" | ||
generate_cert redis "Generic-cert" | ||
|
||
[ -f tests/tls/redis.dh ] || openssl dhparam -out tests/tls/redis.dh 2048 |
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,23 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIID6DCCAdACFCgVz9xx9vFSYlzSZevXgJcfY4cYMA0GCSqGSIb3DQEBCwUAMDUx | ||
EzARBgNVBAoMClJlZGlzIFRlc3QxHjAcBgNVBAMMFUNlcnRpZmljYXRlIEF1dGhv | ||
cml0eTAeFw0yMzA4MDcyMzQ5MjlaFw0yNDA4MDYyMzQ5MjlaMCwxEzARBgNVBAoM | ||
ClJlZGlzIFRlc3QxFTATBgNVBAMMDEdlbmVyaWMtY2VydDCCASIwDQYJKoZIhvcN | ||
AQEBBQADggEPADCCAQoCggEBAJ18FoBNvVEJgHy4ltPSFpANrE/WDIG2NJj58HRI | ||
8I+fuWMcH/zwLDL7BUOFGteYbE24OYWRJLQeC+7F5+bXVuPAX9XuFv4eDu0yJevB | ||
nzx4xCx0V0/dwYrFj8iBD8g1WEhS+I9pMj3ky4CL5Rb6dPAaI9o1yZEDcwTQC62a | ||
r3mU3PYUwiLaUVuMEDjKr2xkl89vcgMcWIPpuICFmU/Qe0dcesoume4Rxbt+oJ4Q | ||
7YBdmQ8AuNHP7zzE7kGVtv5DlUV8B4V7kJIKR/omMUKy2NePtXZs0/g2OLgwceUB | ||
gnOUtN+FX+0GwTeRBWUtGokGLGg2PanTYWUtsIQhJfA9GRsCAwEAATANBgkqhkiG | ||
9w0BAQsFAAOCAgEAdeqnbqxMA3myXUb8Re7luUvAzFxBxYcuF1UORXeES2dex44v | ||
5ZzYj2DSgU65Nz9usjVwKAsQ1gD+8N73RKgCiduAwhzL/P5WEtoM/NfY/ORH81B8 | ||
jXEqm8vlHes6ElCkGNJbuCbkneZpXXE1Hsczpx+zV390ea1iS8s//I3rnBEdX4+X | ||
oD4gUGxGRbbmSjj9jp1mcqHipyDblt5CH/edPN0GxtZROrN2KQSwI3AMx81zPDP7 | ||
Wp/qeukiP6MKU8SGIJJNplApaGxUOdVPLiI4ihCp3ET70L4Yp2Gfo9OVGG+Nev9f | ||
iSdalwQZNz1dzJYkWYKa34G8uqUJ0gFFlwoW6MYTfmbJD4QUd1F1UfVOjA7qSTPY | ||
ih3CidlRR3upDnqexIGXeA3kapT2hSc/Z+4Ch1/q0/9Zn8S1xOL9CmPtWFBe2pcB | ||
b6PnSit+A0pNPEeWLESLlj/pwK7beFcybqKj96MQnHJA+/7VjiNUJGtGiooviiwA | ||
jvh9a1xUzLRxZuq2E6QOHcuJ35k35ghaoHXemmg9ewq1FPjVRHUOym8J6bRveOVC | ||
FBCjOvz1Q6wd8oGNu3S77y5jpm+gNrgYYDsiAj3tK9RzNGUH1gMzM+A5wUlITc8Z | ||
ThHJD/SzEcEgHw54oWgqvRgqUll73Vni4NX9Syw08TIBUQZbOxpDvAQqDmo= | ||
-----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----- | ||
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCdfBaATb1RCYB8 | ||
uJbT0haQDaxP1gyBtjSY+fB0SPCPn7ljHB/88Cwy+wVDhRrXmGxNuDmFkSS0Hgvu | ||
xefm11bjwF/V7hb+Hg7tMiXrwZ88eMQsdFdP3cGKxY/IgQ/INVhIUviPaTI95MuA | ||
i+UW+n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VgvHsYd8/4ZJkmbTUX26vaxXBwS80IlAiQ7xD/Q2B5TaN7uC98I3AoGAV1Cv | ||
nwM1lCbZ8YUBYA+DtdPeqUAftvLeZF19cpikCDKIyoSxy8xel1vzLb/IlejWOkj1 | ||
vjEe2S4QsUs0RGrZGLrULb96YqioaPgJWztezZV8p7wrKD1AQky9dXKO4W8tpNpj | ||
kehxR5yZCwb0dglVP46ecj1Bl0Yyb4EbUCabVskCgYAq7t/AiRY7uJgCwk1Z7ilW | ||
WpqgjaQvYvvCZQMYelJMmSORo0XNyJqVL5y/XqFqbSFLPCYHOv/CjRFCi2UUOjBN | ||
/THiCLEVLBtEkpSNDZr0KJw2X7W9ESOHgRlEF/skZ15xarXhJUa2y265usb1DT8k | ||
Al8XUzTAkpnZoJFfCiUHaQ== | ||
-----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,31 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFSzCCAzOgAwIBAgIUE3AjdeBEjYNnrC8fc9naRo4GpSowDQYJKoZIhvcNAQEL | ||
BQAwNTETMBEGA1UECgwKUmVkaXMgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNhdGUg | ||
QXV0aG9yaXR5MB4XDTIzMDgwNzIzNDkyOFoXDTMzMDgwNDIzNDkyOFowNTETMBEG | ||
A1UECgwKUmVkaXMgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNhdGUgQXV0aG9yaXR5 | ||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyorOJvHFcqrlftg70+Ah | ||
Fg8Q+nNyzOFN9R2YY43vnI28qSbX4j8NFUzVEztXUxvsfiMbwFR2LZn1VUc8qc9S | ||
5BIXdukoohIU0eDwaulskcIzY5//wr8Ous2DWHcbhD7PG2MtqtBFywhO6f0BNz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oDl6D9+xFWJUcUoeDgjq77hn5bxkj | ||
gORxx1rwm0elK1yZT5uGlGY3Udpcfm6ZrD/omreYBdFz7+tvIAGG3JrT2Z9A6Fin | ||
1TvTMQGPDY/lTTwd50modGzLuIDjPe4V5fRceIVuAxhrewpCDvBNNkKYYu+y8ztY | ||
fqIxXhwUhhQegmVtSjZ6ALMyXN2vR0HBiH5B45iFctT/LDi26xeQ1VAX2UYACYen | ||
88pW3XVibPD9om/Nhi33wCdaK//N0C/voOGMovdzB9vUk/YE5U1rHaT6TkaTwGMX | ||
DePwn3469IFqTHy5C/CQ0hc0WpQU3F4N8y8fKVQJPbI5yMUynZJ9p+XnkjPEnNnG | ||
fFRwEKI9ysWmR/aovt0y | ||
-----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
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
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
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,11 @@ | ||
import Redis from 'ioredis' | ||
import {getRedisOptions} from './getRedisOptions' | ||
|
||
// options in outer scope to read from fs only once | ||
const options = getRedisOptions() | ||
|
||
export default class RedisInstance extends Redis { | ||
constructor(connectionName: string) { | ||
super(process.env.REDIS_URL!, {connectionName, ...options}) | ||
} | ||
} |
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
Oops, something went wrong.