I'm using Dropwizard 0.7.0-rc2 for REST API. I have tried configuring SSL through config.yaml and it is working on local machine.
Below is the content in config.yaml
server:
# softNofileLimit: 1000
# hardNofileLimit: 1000
applicationCoectors:
- type: http
port: 8080
- type: https
port: 13790
keyStorePath: xxx.keystore
keyStorePassword: xxx
validateCerts: false
validatePeers: false
#this requires the alpn-boot library on the JVM's boot classpath
#- type: h2
# port: 8445
# keyStorePath: xxx.keystore
# keyStorePassword: xxx
# validateCerts: false
# validatePeers: false
adminCoectors:
- type: http
port: 8081
- type: https
port: 13790
keyStorePath: xxxx.keystore
keyStorePassword: xxxxx
validateCerts: false
validatePeers: false
I tried with this on production server but it gives me the error Failed to parse configuration at: server.applicationCoectors; Could not resolve type id 'http' into a subtype
Then I tried by adding code.
public void run(MyConfiguration configuration, Environment environment)
throws Exception {
((DefaultServerFactory) configuration.getServerFactory()).getApplicationCoectors().add(new HttpsCoectorFactory());
((DefaultServerFactory) configuration.getServerFactory()).getAdminCoectors().add(new HttpsCoectorFactory());
((HttpCoectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getApplicationCoectors().get(0)).setPort(13789);
((HttpCoectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getAdminCoectors().get(0)).setPort(13777);
((HttpsCoectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getApplicationCoectors().get(1)).setPort(13790);
((HttpsCoectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getAdminCoectors().get(1)).setPort(13791);
HttpsCoectorFactory cf1 = (HttpsCoectorFactory) ((HttpCoectorFactory) ((DefaultServerFactory) configuration.getServerFactory()).getApplicationCoectors().get(1));
cf1.setKeyStoreType("JKS");
cf1.setKeyStorePath("/var/***.jks");
cf1.setKeyStorePassword("*****");
cf1.setValidateCerts(true);
cf1.setValidatePeers(true);
}
By above code,it binds the port but fail to coect.
I get following error while testing using openssl
140573632874312:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:598:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : SSLv3
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
Start Time: 1457936036
Timeout : 7200 (sec)
Verify retu code: 0 (ok)
---
I have also tried with using shaded-jar for deployment, but it was not working.
Please help me resolve the issue.
