Creating something like a self-signed certificate can be fiddly so scripting the process makes it repeatable and maintainable. Here’s the batch file template that I use.
mkdir path/to/certificates/
cd path/to/certificates/
# create Certificate Signing Request (csr) and Private Key (key) with no password (-nodes)
openssl req -config path/to/conf/openssl.cnf -out example.com.csr -newkey rsa:2048 -nodes -keyout example.com.key -subj "/C=GB/ST=myCounty/L=myTown/O=myCompany/CN=example.com"
# verify the CSR
openssl req -text -in example.com.csr -noout -verify
openssl req -config path/to/conf/openssl.cnf -keyout example.com.pem -new -out example.com.csr
openssl rsa -in example.com.pem -out example.com.key
openssl x509 -in example.com.csr -out example.com.crt -req -signkey example.com.key -days 999999
openssl x509 -noout -text -in path/to/certificates/example.com.crt