Mujina's SAML Spring Security library requires a private key and public certificate pair for both the Identity Provider (IdP) and the Service Provider (SP).
- Generate the key pair using OpenSSL:
openssl req -subj '/O=Organization, CN=Mujina/' -newkey rsa:2048 -new -x509 -days 3652 -nodes -out mujina.crt -keyout mujina.pem
- Reformat the private key to pkcs8 DER format for Java KeyStore compatibility:
openssl pkcs8 -nocrypt -in mujina.pem -topk8 -out mujina.der
- Clean the files: Remove whitespace, headings, and footers from the
.crt and .der files to get a single-line string.
On Linux:
cat mujina.der |head -n -1 |tail -n +2 | tr -d '\n'; echo
cat mujina.crt |head -n -1 |tail -n +2 | tr -d '\n'; echo
On macOS (requires coreutils via brew install coreutils):
cat mujina.der |ghead -n -1 |tail -n +2 | tr -d '\n'; echo
cat mujina.crt |ghead -n -1 |tail -n +2 | tr -d '\n'; echo
- Update
application.yml: Add the cleaned strings to the configuration.
idp:
private_key: ${output from cleaning the der file}
certificate: ${output from cleaning the crt file}
sp:
private_key: ${output from cleaning the der file}
certificate: ${output from cleaning the crt file}