forked from adap/flower
-
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.
Modify example to start secure server (adap#847)
- Loading branch information
1 parent
b77cb7c
commit 68ec7dd
Showing
7 changed files
with
106 additions
and
9 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
20 changes: 20 additions & 0 deletions
20
examples/advanced_tensorflow/certificates/certificate.conf
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 @@ | ||
[req] | ||
default_bits = 4096 | ||
prompt = no | ||
default_md = sha256 | ||
req_extensions = req_ext | ||
distinguished_name = dn | ||
|
||
[dn] | ||
C = DE | ||
ST = HH | ||
O = Flower | ||
CN = localhost | ||
|
||
[req_ext] | ||
subjectAltName = @alt_names | ||
|
||
[alt_names] | ||
DNS.1 = localhost | ||
IP.1 = ::1 | ||
IP.2 = 127.0.0.1 |
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,52 @@ | ||
#!/bin/bash | ||
# This script will generate all certificates if ca.crt does not exist | ||
|
||
set -e | ||
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../ | ||
|
||
CA_PASSWORD=notsafe | ||
|
||
CERT_DIR=.cache/certificates | ||
|
||
# Generate directories if not exists | ||
mkdir -p .cache/certificates | ||
|
||
# if [ -f ".cache/certificates/ca.crt" ]; then | ||
# echo "Skipping certificate generation as they already exist." | ||
# exit 0 | ||
# fi | ||
|
||
rm -f $CERT_DIR/* | ||
|
||
# Generate the root certificate authority key and certificate based on key | ||
openssl genrsa -out $CERT_DIR/ca.key 4096 | ||
openssl req \ | ||
-new \ | ||
-x509 \ | ||
-key $CERT_DIR/ca.key \ | ||
-sha256 \ | ||
-subj "/C=DE/ST=HH/O=CA, Inc." \ | ||
-days 365 -out $CERT_DIR/ca.crt | ||
|
||
# Generate a new private key for the server | ||
openssl genrsa -out $CERT_DIR/server.key 4096 | ||
|
||
# Create a signing CSR | ||
openssl req \ | ||
-new \ | ||
-key $CERT_DIR/server.key \ | ||
-out $CERT_DIR/server.csr \ | ||
-config ./certificates/certificate.conf | ||
|
||
# Generate a certificate for the server | ||
openssl x509 \ | ||
-req \ | ||
-in $CERT_DIR/server.csr \ | ||
-CA $CERT_DIR/ca.crt \ | ||
-CAkey $CERT_DIR/ca.key \ | ||
-CAcreateserial \ | ||
-out $CERT_DIR/server.pem \ | ||
-days 365 \ | ||
-sha256 \ | ||
-extfile ./certificates/certificate.conf \ | ||
-extensions req_ext |
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