Sunday, April 12, 2015

generate a self signed certification for dropwizard


1. use JDK keytool to generate keystore:

yiyujia@hadoopDev: keytool -genkeypair -keyalg RSA -dname "CN=localhost" -keystore linkedBAC.keystore -keypass 123456 -storepass 12345


2. modify Dropwizard configuration file as bellow.

server:
 #  softNofileLimit: 1000 #  hardNofileLimit: 1000   applicationConnectors:
     - type: http
       port: 8088
     - type: https
       port: 8443
       keyStorePath: linkedBAC.keystore
       keyStorePassword: 123456
       validateCerts: false       validatePeers: false   adminConnectors:
     - type: http
       port: 8081
     - type: https
       port: 8444
       keyStorePath: linkedBAC.keystore
       keyStorePassword: 123456
       validateCerts: false       validatePeers: false

3. Using curl to test your Dropwizard applicaiton.

curl -k --data "user_name=yiyu&password=123456&device_id=1&grant_type=password" https://localhost:8443/oauth2/token/accessToken


4. Or, if want to use web browser to test, we need to add self signged certification as exception by following steps as below.