Skip to content

Instantly share code, notes, and snippets.

@mobmad
Created March 24, 2015 21:37
Show Gist options
  • Save mobmad/433ba54e9cb97d6d7771 to your computer and use it in GitHub Desktop.
Save mobmad/433ba54e9cb97d6d7771 to your computer and use it in GitHub Desktop.
Create self-signed certificate for wiremock and configure a java client under test for HTTPS

1. Generate self-signed certificate

keytool -genkey -alias wiremock -keyalg RSA -keysize 1024 \
    -validity 365 -keypass password -keystore identity.jks -storepass password

Important: keypass must equal storepass, or else you'll receive java.io.IOException: !JsseListener: java.security.UnrecoverableKeyException: Cannot recover key

2. Start wiremock with the new keystore and HTTPS enabled

java -jar wiremock-1.54-standalone.jar --https-port 8081 --https-keystore ./identity.jks

3. Client

Run java with -Djavax.net.ssl.trustStore=/path/to/identity.jks and calls to https://localhost will succeed :-)

Resources

@yaseco
Copy link

yaseco commented Sep 2, 2020

(Client Side)'-Djavax.net.ssl.trustStore=/path/to/identity.jks' won't work properly

explanation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment