В поисках ответа на этот вопрос я наткнулся на http://blog.nanthrax.net/2013/02/multiple-http-connectors-in-apache-karaf/ и Jetty SSL configuration Apache karaf, но эта информация устарела. Я нашел новую документацию по адресу https://www.eclipse.org/jetty/documentation/current/configuring-connectors.html, и примеры отличаются от предложенных конфигураций. Apache Karaf 4.0.2, похоже, использует Jetty 9.Как добавить соединитель SSL для apache karaf?
У меня уже есть хранилище ключей в $ {karaf.home} /etc/keystores/keystore.jks и хотелось бы просто добавить второй разъем ssl на порт 14000. Как сделать это?
Вот мой org.ops4j.pax.web.cfg:
org.osgi.service.http.port=8181
org.osgi.service.http.port.secure=8443
org.osgi.service.http.secure.enabled=true
org.ops4j.pax.web.ssl.keystore=./etc/keystores/keystore.jks
org.ops4j.pax.web.ssl.password=seeburger
org.ops4j.pax.web.ssl.keypassword=seeburger
org.ops4j.pax.web.config.file=${karaf.home}/etc/jetty.xml
Вот мой jetty.xml:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server">
<Ref refid="Server" />
</Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.SslConnectionFactory"></New>
</Item>
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory"></New>
</Item>
</Array>
</Arg>
<Set name="host">
<Property name="jetty.host" default="0.0.0.0" />
</Set>
<Set name="port">
<Property name="jetty.port" default="14000" />
</Set>
<Set name="idleTimeout">
<Property name="http.timeout" default="30000" />
</Set>
<Set name="name">restConnector:14000</Set>
</New>
</Arg>
</Call>
</Configure>
я должен был установить имя, как это обойти в pax- в ArrayIndexOutOfBoundsException 1
веб-мол-4.2.2.jar в org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Stopped.start(ServerControllerImpl.java:503)
:
String[] split = connector.getName().split(":");
if (httpSecurePort == Integer.valueOf(split[1])
.intValue()
&& address.equalsIgnoreCase(split[0])) { ... }
Теперь разъем, кажется, начинается с того, что я вижу в журнал:
2016-02-03 13:39:19,821 | INFO | pool-60-thread-1 | JettyServerImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | Pax Web available at [localhost]:[14000]
2016-02-03 13:39:19,821 | INFO | pool-60-thread-1 | JettyFactoryImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | SPDY not available, creating standard ServerConnector for Http
2016-02-03 13:39:19,822 | INFO | pool-60-thread-1 | JettyServerImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | Pax Web available at [0.0.0.0]:[8181]
2016-02-03 13:39:19,825 | INFO | pool-60-thread-1 | JettyFactoryImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | No ALPN class available
2016-02-03 13:39:19,825 | INFO | pool-60-thread-1 | JettyFactoryImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | SPDY not available, creating standard ServerConnector for Https
2016-02-03 13:39:19,825 | INFO | pool-60-thread-1 | JettyServerImpl | 128 - org.ops4j.pax.web.pax-web-jetty - 4.2.2 | Pax Web available at [0.0.0.0]:[8443]
...
2016-02-03 14:02:03,493 | INFO | pool-54-thread-1 | ContextHandler | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | Started HttpServiceContext{httpContext=org.apache.felix.webconsole.internal.[email protected]}
2016-02-03 14:02:03,493 | INFO | pool-54-thread-1 | Server | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | jetty-9.2.10.v20150310
2016-02-03 14:02:03,571 | INFO | pool-54-thread-1 | ServerConnector | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | Started restConnector:[email protected]{SSL-HTTP/1.1}{0.0.0.0:14000}
2016-02-03 14:02:03,571 | INFO | pool-54-thread-1 | ServerConnector | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | Started [email protected]{HTTP/1.1}{0.0.0.0:8181}
2016-02-03 14:02:03,602 | INFO | pool-54-thread-1 | ServerConnector | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | Started [email protected]{SSL-http/1.1}{0.0.0.0:8443}
2016-02-03 14:02:03,602 | INFO | pool-54-thread-1 | Server | 115 - org.eclipse.jetty.util - 9.2.10.v20150310 | Started @14307ms
Но если я пытаюсь открыть https://localhost:14000/ в моем браузере я получаю ERR_CONNECTION_CLOSED
и следующее исключение:
2016-02-03 15:46:00,509 | DEBUG | qtp427346077-223 | HttpConnection | 79 - org.eclipse.jetty.util - 9.2.10.v20150310 |
javax.net.ssl.SSLHandshakeException: no cipher suites in common
at sun.security.ssl.Handshaker.checkThrown(Handshaker.java:1431)[:1.8.0_60]
...
Caused by: javax.net.ssl.SSLHandshakeException: no cipher suites in common
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)[:1.8.0_60]
ли я что-то пропустил в конфигурации причала?
как альтернатива этому вопросу PAXWEB-907 сделать обновление до Karaf 4.0.4, который включает в себя исправления для этого. –
Я должен придерживаться Karaf 4.0.2 на данный момент. –