123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #!/bin/sh
- PROJECT_NAME="axTLS Project"
- cat > ca_cert.conf << EOF
- [ req ]
- distinguished_name = req_distinguished_name
- prompt = no
- [ req_distinguished_name ]
- O = $PROJECT_NAME Dodgy Certificate Authority
- EOF
- cat > certs.conf << EOF
- [ req ]
- distinguished_name = req_distinguished_name
- prompt = no
- [ req_distinguished_name ]
- O = $PROJECT_NAME
- CN = 127.0.0.1
- EOF
- cat > device_cert.conf << EOF
- [ req ]
- distinguished_name = req_distinguished_name
- prompt = no
- [ req_distinguished_name ]
- O = $PROJECT_NAME Device Certificate
- EOF
- openssl genrsa -out axTLS.ca_key.pem 1024
- openssl genrsa -out axTLS.key_512.pem 512
- openssl genrsa -out axTLS.key_1024.pem 1024
- openssl genrsa -out axTLS.key_2048.pem 2048
- openssl genrsa -out axTLS.key_4096.pem 4096
- openssl genrsa -out axTLS.device_key.pem 1024
- openssl genrsa -aes128 -passout pass:abcd -out axTLS.key_aes128.pem 512
- openssl genrsa -aes256 -passout pass:abcd -out axTLS.key_aes256.pem 512
- openssl rsa -in axTLS.key_512.pem -out axTLS.key_512 -outform DER
- openssl rsa -in axTLS.key_1024.pem -out axTLS.key_1024 -outform DER
- openssl rsa -in axTLS.key_2048.pem -out axTLS.key_2048 -outform DER
- openssl rsa -in axTLS.key_4096.pem -out axTLS.key_4096 -outform DER
- openssl rsa -in axTLS.device_key.pem -out axTLS.device_key -outform DER
- openssl req -out axTLS.ca_x509.req -key axTLS.ca_key.pem -new \
- -config ./ca_cert.conf
- openssl req -out axTLS.x509_512.req -key axTLS.key_512.pem -new \
- -config ./certs.conf
- openssl req -out axTLS.x509_1024.req -key axTLS.key_1024.pem -new \
- -config ./certs.conf
- openssl req -out axTLS.x509_2048.req -key axTLS.key_2048.pem -new \
- -config ./certs.conf
- openssl req -out axTLS.x509_4096.req -key axTLS.key_4096.pem -new \
- -config ./certs.conf
- openssl req -out axTLS.x509_device.req -key axTLS.device_key.pem -new \
- -config ./device_cert.conf
- openssl req -out axTLS.x509_aes128.req -key axTLS.key_aes128.pem \
- -new -config ./certs.conf -passin pass:abcd
- openssl req -out axTLS.x509_aes256.req -key axTLS.key_aes256.pem \
- -new -config ./certs.conf -passin pass:abcd
- openssl x509 -req -in axTLS.ca_x509.req -out axTLS.ca_x509.pem \
- -sha1 -days 10000 -signkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_512.req -out axTLS.x509_512.pem \
- -sha1 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_1024.req -out axTLS.x509_1024.pem \
- -sha1 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_2048.req -out axTLS.x509_2048.pem \
- -md5 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_4096.req -out axTLS.x509_4096.pem \
- -md5 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_device.req -out axTLS.x509_device.pem \
- -sha1 -CAcreateserial -days 10000 \
- -CA axTLS.x509_512.pem -CAkey axTLS.key_512.pem
- openssl x509 -req -in axTLS.x509_aes128.req \
- -out axTLS.x509_aes128.pem \
- -sha1 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- openssl x509 -req -in axTLS.x509_aes256.req \
- -out axTLS.x509_aes256.pem \
- -sha1 -CAcreateserial -days 10000 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- DATE_NOW=`date`
- if date -s "Jan 1 2025"; then
- openssl x509 -req -in axTLS.x509_512.req -out axTLS.x509_bad_before.pem \
- -sha1 -CAcreateserial -days 365 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- date -s "$DATE_NOW"
- touch axTLS.x509_bad_before.pem
- fi
- openssl x509 -req -in axTLS.x509_512.req -out axTLS.x509_bad_after.pem \
- -sha1 -CAcreateserial -days -365 \
- -CA axTLS.ca_x509.pem -CAkey axTLS.ca_key.pem
- rm axTLS*.req
- rm axTLS.srl
- rm *.conf
- openssl x509 -in axTLS.ca_x509.pem -outform DER -out axTLS.ca_x509.cer
- openssl x509 -in axTLS.x509_512.pem -outform DER -out axTLS.x509_512.cer
- openssl x509 -in axTLS.x509_1024.pem -outform DER -out axTLS.x509_1024.cer
- openssl x509 -in axTLS.x509_2048.pem -outform DER -out axTLS.x509_2048.cer
- openssl x509 -in axTLS.x509_4096.pem -outform DER -out axTLS.x509_4096.cer
- openssl x509 -in axTLS.x509_device.pem -outform DER -out axTLS.x509_device.cer
- openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted_pem.p8
- openssl pkcs8 -in axTLS.key_512.pem -passout pass:abcd -topk8 -outform DER -v1 PBE-SHA1-RC4-128 -out axTLS.encrypted.p8
- openssl pkcs8 -in axTLS.key_512.pem -nocrypt -topk8 -out axTLS.unencrypted_pem.p8
- openssl pkcs8 -in axTLS.key_512.pem -nocrypt -topk8 -outform DER -out axTLS.unencrypted.p8
- openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -certfile axTLS.ca_x509.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_with_CA" -out axTLS.withCA.p12 -password pass:abcd
- openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -name "p12_without_CA" -out axTLS.withoutCA.p12 -password pass:abcd
- openssl pkcs12 -export -in axTLS.x509_1024.pem -inkey axTLS.key_1024.pem -keypbe PBE-SHA1-RC4-128 -certpbe PBE-SHA1-RC4-128 -out axTLS.noname.p12 -password pass:abcd
- cat axTLS.ca_x509.pem >> axTLS.x509_device.pem
- xxd -i axTLS.x509_1024.cer | sed -e \
- "s/axTLS_x509_1024_cer/default_certificate/" > ../../ssl/cert.h
- xxd -i axTLS.key_1024 | sed -e \
- "s/axTLS_key_1024/default_private_key/" > ../../ssl/private_key.h
|