Embedded jetty + ssl (https)

1,631 views
Skip to first unread message

Kari Skyttä

unread,
Aug 13, 2014, 9:10:57 AM8/13/14
to spar...@googlegroups.com
Hi!

Does anybody have any sample howto enable ssl (https) in spark and embedded jetty? Or is it even possible?

Kari Skyttä

unread,
Aug 13, 2014, 9:23:21 AM8/13/14
to spar...@googlegroups.com
Maybe I could use Apache Web server as reverse proxy? Or is there any other solution?

Christian MICHON

unread,
Aug 13, 2014, 11:08:02 AM8/13/14
to spar...@googlegroups.com
Hi,


You'll need to setup a JKS keystore (google for ImportKey.java), but once it's done, it really works! (I've done it on hellosecureworld)

Kari Skyttä

unread,
Aug 13, 2014, 3:40:42 PM8/13/14
to spar...@googlegroups.com
Thanks Christian, I will try that :)

Christian MICHON

unread,
Aug 20, 2014, 8:41:41 AM8/20/14
to spar...@googlegroups.com
well, this example from github was based on the old Spark api I suppose. I tested this before v2.0.0...

Now you need to use something like SparkBase.setSecure('keystore.jks','secret',null,null) to get it to work in Spark 2.0.0...

Good luck!

a platypus

unread,
Sep 10, 2014, 10:07:58 PM9/10/14
to spar...@googlegroups.com

Yes Kari,

 I can confirm that worked for me this week.

w.

Kari Skyttä

unread,
Sep 15, 2014, 4:01:21 PM9/15/14
to spar...@googlegroups.com
Thanks a lot. It worked me too. :)

ed

unread,
Sep 29, 2015, 8:54:54 AM9/29/15
to sparkjava
I'm using the spark framework, trying to add HTTPS. I have an SSL certificate(certificate.crt) purchased which i've added to the Java keystore using Import Java. I've then included 

secure("keystore.jks", "somepassword", null, null);

The output after running the code is:

[Thread-0] INFO org.eclipse.jetty.util.log - Logging initialized @898ms
[Thread-0] INFO spark.webserver.JettySparkServer - == Spark has ignited ...
[Thread-0] INFO spark.webserver.JettySparkServer - >> Listening on 0.0.0.0:443
[Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.3.z-SNAPSHOT
[Thread-0] INFO org.eclipse.jetty.util.ssl.SslContextFactory - x509={} wild={} alias=null for SslContextFactory@5cee0391(file:///root/keystore.jks,null)
[Thread-0] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@59c326cc{SSL,[ssl, http/1.1]}{0.0.0.0:443}
[Thread-0] INFO org.eclipse.jetty.server.Server - Started @1717ms

On posting to my webservice, i get the error:  The response status was 0. Help

On Wednesday, August

Wellington Calligaris

unread,
Dec 11, 2015, 11:10:20 AM12/11/15
to sparkjava
Same issue here...
Reply all
Reply to author
Forward
0 new messages