bbyars / mountebank

Over the wire test doubles
http://www.mbtest.org
MIT License
2k stars 262 forks source link

fix: increase https default cert and key length to 2048 for node 18 #732

Closed MakersAll8 closed 1 year ago

MakersAll8 commented 1 year ago

in host terminal build the image and tag it as generate_key
docker build -t generate_key --rm .

spin up a container based on the image
docker run --rm -v $PWD/key:/home/ubuntu/key -it --entrypoint /bin/bash generate_key

run the following command in the container CLI

export ROOT_CA_PASSWORD=$(echo $RANDOM | md5sum | head -c 30) && \
openssl genrsa -des3 -passout pass:$ROOT_CA_PASSWORD -out developmentCA.key 2048 && \
openssl req -x509 -new -nodes -key developmentCA.key -sha256 -days 3650 -out developmentCA.crt \
-subj "/C=US/ST=TX/L=Dallas/O=mountebank/CN=mountebank" \
-passin pass:$ROOT_CA_PASSWORD && \
openssl genrsa -out localhost.key 2048 && \
openssl req -new -sha256 -key localhost.key \
-subj "/C=US/ST=TX/L=Dallas/O=mountebank/CN=mountebank" \
-out localhost.csr && openssl x509 \
-req -in localhost.csr -CA developmentCA.crt -extensions SAN \
-CAkey developmentCA.key -CAcreateserial -out localhost.crt -days 3650 -sha256 \
-passin pass:$ROOT_CA_PASSWORD && \
openssl x509 -in localhost.crt -text -noout

In your key folder on host machine where you created the Dockerfile above, you should have a bunch of private keys, public keys, certificate signing request, etc. Only localhost.key and localhost.crt are of interests to us, the rest were created to eventually get the self-signed certificate localhost.crt.

Copy localhost.key into the key field in the imposters.ejs file, and localhost.crt into cert.

bbyars commented 1 year ago

Thanks!