#!/bin/sh

OPENSSL=/home/product/code/firmware/current/bin/openssl
CONF=/home/product/code/config/ssl.conf
CSR=/home/product/code/config/ssl_csr.pem
KEY=/home/product/code/config/ssl_private_key.pem
CERTSERIAL=`/home/product/code/firmware/current/bin/ssl_inc_serial.pl /home/product/code/config/ssl_csr.srl`

# create private key without file encryption
if [ ! -f $KEY ]; then
    $OPENSSL genrsa -out $KEY 1024
fi

$OPENSSL req -new -batch -key $KEY -config $CONF -set_serial $CERTSERIAL -out $CSR

# test using
# openssl req -noout -text -in domainname.csr
