Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools fixes #336

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions tools/makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Expand All @@ -29,7 +29,7 @@ else
TrueCA=0

# Generate the openssl configuration files.
cat > ca_cert.conf << EOF
cat > ca_cert.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
Expand All @@ -38,7 +38,7 @@ prompt = no
O = $PROJECT_NAME Dodgy Certificate Authority
EOF


openssl genrsa -out ca.key 1024 #you can change number 1024 if encryption bits is required
openssl req -out ca.req -key ca.key -new -config ./ca_cert.conf

Expand All @@ -55,7 +55,7 @@ fi
cp TLS.ca_x509.cer ca/
cp make_cacert.py ca/
cd ca/
python make_cacert.py
python2 make_cacert.py
cd ..
cp ca/esp_ca_cert.bin bin/
cp ca.crt ca/
Expand All @@ -65,7 +65,7 @@ echo esp_ca_cert.bin generated OK\!
if [ $TrueCA -eq 1 ];then
echo trust CA
if [ -f "client.crt" ] && [ -f "client.key" ]; then
echo client.crt \&\& client.key are found, generating esp_cert_private_key.bin
echo client.crt \&\& client.key are found, generating esp_cert_private_key.bin
mkdir client
mkdir include
openssl rsa -in client.key -out TLS.key_1024.bak -outform DER
Expand All @@ -81,8 +81,8 @@ if [ $TrueCA -eq 1 ];then
mv client/TLS.key_1024 client/private_key.key_1024
cp make_cert.py client/
cd client
python make_cert.py

python2 make_cert.py
rm make_cert.py
mv esp_cert_private_key.bin ../bin/
cd ..
Expand All @@ -95,7 +95,7 @@ if [ $TrueCA -eq 1 ];then
"s/TLS_key_1024/default_private_key/" > private_key.h
cp cert.h private_key.h include/
cp client.crt client.key client/

elif [ -f "server.crt" ] && [ -f "server.key" ]; then
echo server.crt \&\& server.key are found, generating esp_cert_private_key.bin
mkdir server
Expand All @@ -113,8 +113,8 @@ if [ $TrueCA -eq 1 ];then
mv server/TLS.key_1024 server/private_key.key_1024
cp make_cert.py server/
cd server
python make_cert.py

python2 make_cert.py
rm make_cert.py
mv esp_cert_private_key.bin ../bin/
cd ..
Expand All @@ -136,7 +136,7 @@ elif [ $TrueCA -eq 0 ];then
mkdir client
mkdir include

cat > server_cert.conf << EOF
cat > server_cert.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
Expand All @@ -146,7 +146,7 @@ prompt = no
CN = 192.168.111.100
EOF

cat > client_cert.conf << EOF
cat > client_cert.conf << EOF
[ req ]
distinguished_name = req_distinguished_name
prompt = no
Expand All @@ -163,8 +163,8 @@ EOF
openssl rsa -in client.key -out TLS.key_1024.bak -outform DER
openssl rsa -in TLS.key_1024.bak -out TLS.key_1024 -inform DER

openssl req -out server.req -key server.key -new -config ./server_cert.conf
openssl req -out client.req -key client.key -new -config ./client_cert.conf
openssl req -out server.req -key server.key -new -config ./server_cert.conf
openssl req -out client.req -key client.key -new -config ./client_cert.conf

openssl x509 -req -in server.req -out server.crt -sha1 -CAcreateserial -days 5000 -CA ca.crt -CAkey ca.key
openssl x509 -req -in client.req -out client.crt -sha1 -CAcreateserial -days 5000 -CA ca.crt -CAkey ca.key
Expand All @@ -180,8 +180,8 @@ EOF
mv client/TLS.key_1024 client/private_key.key_1024
cp make_cert.py client/
cd client
python make_cert.py

python2 make_cert.py
rm make_cert.py
mv esp_cert_private_key.bin ../bin/
cd ..
Expand All @@ -203,14 +203,14 @@ fi

#delete intermediate file

rm ca/make_cacert.py ca/esp_ca_cert.bin -rf
rm *.conf -rf
rm *.req -rf
rm *.h -rf
rm *.bak
rm *.srl -rf
rm -rf ca/make_cacert.py ca/esp_ca_cert.bin
rm -rf *.conf
rm -rf *.req
rm -rf *.h
rm -rf *.bak
rm -rf *.srl

find -name \*.cer | xargs rm -f
find -name \*.key_1024 | xargs rm -f
find . -name \*.cer | xargs rm -f
find . -name \*.key_1024 | xargs rm -f

echo esp_ca_cert.bin \&\& esp_cert_private_key.bin was generated under bin\/ directory
29 changes: 13 additions & 16 deletions tools/rmfile.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
rm *.pem -rf
rm *.srl -rf
rm *.h -rf
rm *.cer -rf
rm *.key_1024 -rf
rm *.req -rf
rm *.conf -rf
rm *.bak -rf

rm ca/ -rf
rm bin/ -rf
rm server/ -rf
rm client/ -rf
rm include/ -rf


rm -rf *.pem
rm -rf *.srl
rm -rf *.h
rm -rf *.cer
rm -rf *.key_1024
rm -rf *.req
rm -rf *.conf
rm -rf *.bak

rm -rf ca/
rm -rf bin/
rm -rf server/
rm -rf client/
rm -rf include/