I am trying to set up SSL in my Dropwizard server. I have got my SSL from GoDaddy and have received a couple of files from them namely:
I have added the gd_bundle-g2-g1.crt certificate with alias root in my keystore and have added the other one with my domain alias.
My .yml configuration file looks like this: (I have just pasted the relevant section of the .yml file)
server:
applicationConnectors:
- type: http
port: 8080
- type: https
port: 8443
keyStorePath: keystore/myKeyStore.jks
keyStorePassword: "myPassword"
validateCerts: true
adminConnectors:
- type: http
port: 8081
The problem is that whenever I am trying to launch my server I am receiving the following error:
java.lang.IllegalStateException: Unable to retrieve certificate chain
When I set the validateCerts as false in the .yml above then, for obvious reason, this error goes away but when I try to access the URL I get:
Connection closed error when trying to access the URL
I seem to be stuck real bad. My server is working perfectly with http but https just doesn't work! :(
Given my end goal of making https work and my current scenario, I have the following questions:
Appreciate your help.
Dropwizard is an open-source Java framework used for the fast development of high-performance RESTful web services. It gathers some popular libraries to create the light-weight package. The main libraries that it uses are Jetty, Jersey, Jackson, JUnit, and Guava. Furthermore, it uses its own library called Metrics.
Dropwizard uses Logback for its logging backend. It provides an slf4j implementation, and even routes all java. util. logging , Log4j, and Apache Commons Logging usage through Logback.
Registering A Resource A Dropwizard application can contain many resource classes, each corresponding to its own URI pattern. Just add another @Path -annotated resource class and call register with an instance of the new class. Before we go too far, we should add a health check for our application.
The issue is finally resolved! Here is how I got it to work (hope this helps anyone who is having a hard time figuring out how to make SSL work with Dropwizard)
b78*********.crt
and gd_bundle-g2-g1.crt
(make sure that the contents of the b78*********.crt
are before the other file). Let's refer to that file as all_combined.crt from now.C:\xampp\apache\bin>openssl.exe pkcs12 -export -in all_combined.crt -inkey myKey.key -out keystore.p12 -CAfile temp.crt
myKey.key is the file that you must have created while generating the CSR to request the SSL from the authority.
C:\Program Files\Java\jdk1.8.0_65\bin\keystore>..\keytool.exe -importkeystore -srckeystore keystore.p12 -destkeystore myKeyStore.jks -srcstoretype pkcs12 -deststoretype jks
That's all what is required in the keystore.
server: applicationConnectors: - type: http port: 8080 - type: https port: 8443 keyStorePath: ./keystore/myKeyStore.jks keyStorePassword: "myPassword" validateCerts: false validatePeers: false
Note that I have set the validateCerts and validatePeers to false. Then I just restarted my Dropwizard server and everything started working as expected and my server was listening and responding to port 8443! :-)
PS: I am not 100% sure on what each step does or whether each of these are required. But after searching for hours and hours I've finally got something to work and would definitely read about the details of this later when I have some time. Till then hope this unblocks someone who's stuck on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With