-
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.
test: Fix certificate being not trusted on MacOS
- Loading branch information
Showing
10 changed files
with
56 additions
and
143 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,36 @@ | ||
#!/bin/sh | ||
set -eux | ||
|
||
openssl req -x509 -new -nodes -sha256 -newkey rsa:2048 \ | ||
-keyout server.key \ | ||
-out server.crt \ | ||
-subj "/C=DE/CN=example.org" \ | ||
-addext "subjectAltName = DNS:zitadel, DNS:localhost" | ||
|
||
# These keys are not actually secret, and when passed into the docker | ||
# container the server key needs to be readable by the container user | ||
chmod go+r server.key | ||
|
||
openssl x509 -outform pem -in server.crt -out ca.crt | ||
openssl req -x509 -nodes -days 3650 -sha256 -newkey rsa:2048 \ | ||
-CAkey server.key \ | ||
-CA ca.crt \ | ||
-keyout client.key \ | ||
-out client.crt \ | ||
-subj "/CN=admin.example.org" | ||
script_dir=$(dirname $0) | ||
|
||
file_creation=$(date -r $script_dir/ca.crt +%s || echo 0) | ||
|
||
if [ $(( $(date +%s) - $file_creation )) -gt 2160000 ]; # 25 days old? | ||
then | ||
|
||
# We need to set EKUs (extendedKeyUsage) otherwise MacOS won't trust | ||
# the certificate | ||
openssl req -x509 -new -nodes -sha256 -newkey rsa:2048 \ | ||
-keyout $script_dir/server.key \ | ||
-out $script_dir/server.crt \ | ||
-subj "/C=DE/CN=example.org" \ | ||
-addext "subjectAltName = DNS:zitadel, DNS:localhost" \ | ||
-addext "extendedKeyUsage = serverAuth, clientAuth" | ||
|
||
# These keys are not actually secret, and when passed into the docker | ||
# container the server key needs to be readable by the container user | ||
chmod go+r $script_dir/server.key | ||
|
||
openssl x509 -outform pem -in $script_dir/server.crt -out $script_dir/ca.crt | ||
openssl req -x509 -nodes -days 3650 -sha256 -newkey rsa:2048 \ | ||
-CAkey $script_dir/server.key \ | ||
-CA $script_dir/ca.crt \ | ||
-keyout $script_dir/client.key \ | ||
-out $script_dir/client.crt \ | ||
-subj "/CN=admin.example.org" | ||
|
||
chmod a+r $script_dir/client.key | ||
chmod a+r $script_dir/client.crt | ||
chmod a+r $script_dir/server.crt | ||
|
||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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