0
我正嘗試創建一個使用Groovy進行SSL工作的HttpServer,但是我無法使其工作,並且找不到有關它的良好代碼示例或文檔。運行Vertx httpServer SSL groovy
這裏說我這樣做是遠遠
Map options = new HashMap()
options.put("tcpKeepAlive",true)
options.put("verifyHost", true)
options.put("trustAll", false)
options.put("keyCertOptions", new JksOptions().setPath("keystore.jks").setPassword("CosPassword123"))
options.put("ssl", true)
vertx.createHttpServer(options).requestHandler(router.&accept).listen(9000, { response ->
if (response.succeeded()) {
startFuture.complete()
} else {
startFuture.fail(response.cause())
}
})
當我運行它,我收到異常
io.vertx.core.VertxException: io.vertx.core.VertxException: Key/certificate is mandatory for SSL
at io.vertx.core.net.impl.SSLHelper.createContext(SSLHelper.java:303)
at io.vertx.core.net.impl.SSLHelper.getContext(SSLHelper.java:458)
at io.vertx.core.net.impl.SSLHelper.validate(SSLHelper.java:472)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:219)
at io.vertx.core.http.impl.HttpServerImpl.listen(HttpServerImpl.java:191)
at io.vertx.groovy.core.http.HttpServer.listen(HttpServer.groovy:178)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:190)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at com.tesco.price.mocks.identity.IdentityMock.startServer(IdentityMock.groovy:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
at com.tesco.price.mocks.identity.IdentityMock.start(IdentityMock.groovy:29)
at io.vertx.lang.groovy.GroovyVerticle$1.start(GroovyVerticle.groovy:93)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:434)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(ContextImpl.java:359)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:339)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:393)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
at java.lang.Thread.run(Thread.java:745)
我有一個工作的httpd SSL配置:1.了SSLCertificateFile certificate.cer,2.了SSLCertificateKeyFile privatekey.key 3. SSLCertificateChainFile intermediate.cer。我需要爲vertx 3創建一個java keystore(.jks)。我所有的嘗試都會導致瀏覽器發生錯誤:www.mydomain.de使用無效的安全證書。證書不可信,因爲發行者證書是未知的。服務器可能不會發送適當的中間證書。可能需要導入額外的根證書。錯誤代碼:SEC_ERROR_UNKNOWN_ISSUER。你能解釋一下遷移步驟嗎? – Michael