How to enable HTTPS for standalone Wiremock

后端 未结 2 1016
北恋
北恋 2021-01-03 03:12

Overview:

I used wiremock standalone 2.1.11 and did the following to enable HTTPS URL for my request but to no avail:

  • Studying the d
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 03:41

    1. Generate java key store for wiremock

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

      Important --- Follow the prompts to specify the certificate details:

      • First and last name: this is not your name, it is the Common Name (CN), for example 'confluence.example.com'. The CN must match the fully qualified hostname of the server running Confluence, or Tomcat won't be able to use the certificate for SSL.
      • Organizational unit: this is the team or department requesting the certificate, for example 'marketing'.
      • Organization: this is your company name, for example 'SeeSpaceEZ'. City, State / province, country code: this is where you're located, for example Sydney, NSW, AU.
    2. Create the self-signed certification

      openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -config localhost.conf
      
    3. Import certification into keystore

       keytool -import -trustcacerts -alias mock -file localhost.crt -keystore identity.jks
      
    4. Start wiremock with the new keystore and HTTPS enabled

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

    Resources:

    The answer is from https://gist.github.com/mobmad/433ba54e9cb97d6d7771#1-generate-self-signed-certificate

提交回复
热议问题