This repository contains a script to generate SSL certificates and keystores using mkcert
, and configure them for a Spring Boot application. The script will generate PEM files (key.pem
and cert.pem
), a PKCS12 keystore (keystore.p12
), and optionally a Java KeyStore (JKS) (keystore.jks
).
Ensure the following tools are installed on your system:
The script will:
- Create an SSL directory.
- Generate a private key and certificate using
mkcert
. - Convert the generated PEM files into a PKCS12 keystore.
- Optionally convert the PKCS12 keystore to a JKS keystore.
- Prompt for a keystore password, use an environment variable if set, or use a default password.
-
Clone the repository (if applicable):
git clone <repository-url> cd <repository-directory>
-
Make the script executable:
chmod +x generate-ssl-certificate.sh
-
Run the script:
./generate-ssl-certificate.sh
You can specify a custom base directory as the first argument:
./generate-ssl-certificate.sh /path/to/directory
The script will prompt you to enter a keystore password. If you don't provide one, it will use the password from the environment variable
SSL_KEYSTORE_PASSWORD
if set, or default tochangeme
.
You can set the keystore password via an environment variable SSL_KEYSTORE_PASSWORD
:
export SSL_KEYSTORE_PASSWORD=mysecurepassword
Or in Windows:
set SSL_KEYSTORE_PASSWORD=mysecurepassword
The script will generate the following files in the ssl directory:
key.pem
: Private keycert.pem
: Certificatekeystore.p12
: PKCS12 keystorekeystore.jks
: Java KeyStore (optional)