harasho/certs/more.sh

30 lines
1.2 KiB
Bash
Raw Normal View History

2023-05-25 23:56:36 +00:00
#!/bin/bash
echo "This script removes all cert files in the directory."
echo "Continue? Press enter!"
read
2023-05-26 02:59:30 +00:00
rm *.key *.csr *.crt *.pem > /dev/null
2023-05-25 23:56:36 +00:00
# Generate Root Certificate and Key
2023-05-26 02:59:30 +00:00
openssl req -newkey rsa:2048 -nodes -keyout root.key -x509 -days 3650 -out root.csr -subj "/C=JP/ST=A/L=A/CN=Taito Arcade Machine CA"
2023-05-25 23:56:36 +00:00
# Generate Second Certificate and Key
openssl req -newkey rsa:2048 -nodes -keyout nesys.key -out nesys.csr -subj "/C=JP/ST=A/L=A/CN=nesys"
2023-05-26 02:59:30 +00:00
# Sign with root cert
openssl x509 -req -in nesys.csr -CA root.csr -CAkey root.key -CAcreateserial -out nesys.csr -days 1825
2023-05-25 23:56:36 +00:00
# Generate Last Certificate and Key
openssl req -newkey rsa:2048 -nodes -keyout nesica1.key -out nesica1.csr -subj "/C=JP/ST=A/L=A/CN=nesica1"
2023-05-26 02:59:30 +00:00
# Add domains
echo "subjectAltName = DNS:cert.nesys.jp,DNS:cert3.nesys.jp,DNS:data.nesys.jp,DNS:proxy.nesys.jp,DNS:nesys.taito.co.jp,DNS:fjm170920zero.nesica.net" > cert.ext
openssl req -in nesica1.csr -out nesica1.csr -config cert.ext
# Sign with nesys cert
openssl x509 -req -in nesica1.csr -CA nesys.csr -CAkey nesys.key -CAcreateserial -out nesica1.csr -days 730
openssl x509 -in nesica1.csr -out cert.pem -outform PEM
openssl rsa -in nesica1.key -out key.pem -outform PEM
2023-05-25 23:56:36 +00:00
echo "Use nesica1.pem and nesica1.key for the webserver!"