Open sibwaf opened 7 years ago
Hmm, this should be fixed by the latest push to master. Please try it out! Edit: this response was a bit stressed, I might be totally wrong
Nope, still no good. There is still no Http#secure(...) overload that takes no truststore parameters. What I mean is there should be a method like Http#secure(keystoreFile, keystorePassword). Though I'm not completely sure this is valid, but it doesn't seem that truststore is required for SSL to work (I might be completely wrong).
Also DSL works kind of bad.
1) When truststore parameters are not provided, it just crashes with this exception:
java.lang.IllegalStateException: no valid keystore at org.eclipse.jetty.util.security.CertificateUtils.getKeyStore(CertificateUtils.java:48) at org.eclipse.jetty.util.ssl.SslContextFactory.loadTrustStore(SslContextFactory.java:1043) at org.eclipse.jetty.util.ssl.SslContextFactory.load(SslContextFactory.java:255) at org.eclipse.jetty.util.ssl.SslContextFactory.doStart(SslContextFactory.java:220) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113) at org.eclipse.jetty.server.SslConnectionFactory.doStart(SslConnectionFactory.java:72) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113) at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:270) at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81) at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at org.eclipse.jetty.server.Server.doStart(Server.java:431) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) at spark.embeddedserver.jetty.EmbeddedJettyServer.ignite(EmbeddedJettyServer.java:130) at spark.Service.lambda$init$2(Service.java:504) at java.lang.Thread.run(Thread.java:748)
2) If route mappings are provided inside DSL configuration, HTTPS is ignored for them completely.
ignite { secure { ... } get("/") { "Hey" } }
3) Following code crashes, as it seems Spark is trying to create multiple servers for whatever reason:
ignite { get("/") { "Hey1" } }.get("/") { "Hey2" }
4) Stdout-debugging when igniting with DSL. Not good.
Spark for Java allows passing nulls for truststoreFile and truststorePassword, while Spark for Kotlin for some reason doesn't, because these parameters are specified as non-nullable.
Possible solutions: 1) Just specify them as nullable 2) Specify them as nullable and add a default value 3) Add an overloading function which doesn't take truststore parameters at all