29 lines
993 B
Bash
29 lines
993 B
Bash
#! /bin/bash
|
|
|
|
## path: /home/script/auto_cert.sh
|
|
|
|
## Fuer die manuelle Eingabe eines Geraetenamen
|
|
# echo "hallo , geben Sie ein Hostnamen fuer ihr Geraet ein"
|
|
# read CN
|
|
|
|
## Erzeugung von rsa key files
|
|
CN=$1
|
|
openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -subj "/CN=${CN}"
|
|
|
|
## Ermittlung des primary fingerprint und uebermittlung per bluetooth
|
|
Fingerprint=$(openssl x509 -noout -fingerprint -sha256 -in cert.pem | sed -e "s|:||g" | sed -e "s|SHA256||g" | sed$
|
|
echo $Fingerprint
|
|
echo "fingerprint ${Fingerprint}" > /dev/service
|
|
|
|
## Anpassung der key files und verschiebung in das zugehoerige directory
|
|
chmod 600 key.pem
|
|
chmod 600 cert.pem
|
|
Pathssl=/etc/ssl
|
|
mv key.pem $Pathssl/private
|
|
mv cert.pem $Pathssl/certs
|
|
Pathcert=$Pathssl/certs/cert.pem
|
|
Pathkey=$Pathssl/private/key.pem
|
|
|
|
## Configures the device for communication with the cloud
|
|
/home/script/auto_conf.sh -enabled true -clientid ${CN} -host mm-hfu-semesterprojekt.azure-devices.net -usetls fal$
|