Curl doesn't have support for java keystore file, so therefor the file should be converted to a PEM format. It consists of the following multiple steps:
- Convert keystore to p12 file
- Convert p12 file to pem file
- Run curl command with pem files
keytool -importkeystore -srckeystore truststore.jks \
-destkeystore truststore.p12 \
-srcstoretype JKS \
-deststoretype PKCS12 \
-deststorepass password \
-srcstorepass password \
-noprompt
openssl pkcs12 -in truststore.p12 -passin pass:password -out truststore.pem
curl secret --cacert truststore.pem https://localhost:8443/api/hello
Example curl request for mutual authentication, loading trusted certificates and loading private and public key of the client:
Repeat step 1 (if applicable) choosing the correct alias and step 2 for the identity.jks, but with different options, which contains the keypair.
keytool -importkeystore -srckeystore keystore.jks \
-destkeystore client.pfx -deststoretype PKCS12 \
-srcalias mykey \
-deststorepass password \
-destkeypass password \
-srcstorepass password \
-noprompt
openssl pkcs12 -in client.pfx -passin pass:password -out client.p12 -nodes
Then call cURL
curl --cert identity.pem --cacert truststore.pem https://localhost:8443/api/hello