(Steps taken from: https://www.baeldung.com/x-509-authentication-in-spring-security)
All passwords: changeit
openssl req -x509 -sha256 -days 3650 -newkey rsa:4096 -keyout rootCA.key -out rootCA.crt
openssl req -new -newkey rsa:4096 -keyout localhost.key -out localhost.csr -nodes
Sign host csr with rootCA (see below for file localhost.ext
):
openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in localhost.csr -out localhost.crt -days 365 -CAcreateserial -extfile localhost.ext
openssl req -new -newkey rsa:4096 -nodes -keyout fredFlintstone.key -out fredFlintstone.csr
Sign client csr with rootCA:
openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in fredFlintstone.csr -out fredFlintstone.crt -days 365 -CAcreateserial
Import client key and crt in keystore to create the "certificate" to be used in the browser:
openssl pkcs12 -export -out fredFlintstone.p12 -name "fredFlintstone" -inkey fredFlintstone.key -in fredFlintstone.crt