client-certificate authentication on jetty (karaf)

送分小仙女□ 提交于 2019-12-22 11:11:25

问题


I need to do client authentication using certificate on jetty server.

I have done this on Tomcat using:

<Connector
           protocol="org.apache.coyote.http11.Http11Protocol"
           port="8443" maxThreads="200"
           minSpareThreads="5" 
           enableLookups="true" disableUploadTimeout="true"
           acceptCount="100"
           scheme="https" secure="true" SSLEnabled="true"
           keystoreFile="D:\certificates\certs\server.jks" keystoreType="JKS" keystorePass="password"
           truststoreFile="D:\certificates\certs\trust_store.jks" truststoreType="JKS" truststorePass="password"
           clientAuth="true"
           sslProtocol="TLS"/>

But i want to do it on karaf, so i learned that i could do it by adding following on jetty.xml :

<Call name="addConnector">
 <Arg>
   <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
     <Arg>
       <New class="org.eclipse.jetty.http.ssl.SslContextFactory">
         <Set name="KeyStore">./etc/keystores/server.jks</Set>
         <Set name="KeyStorePassword">password</Set>
         <Set name="KeyManagerPassword">password</Set>
         <Set name="TrustStore">./etc/keystores/trust_store.jks</Set>
         <Set name="TrustStorePassword">password</Set>
       </New>
     </Arg>
     <Set name="port">8443</Set>
     <Set name="maxIdleTime">30000</Set>
   </New>
 </Arg>

and following on org.ops4j.pax.web.xml :

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=password
org.ops4j.pax.web.ssl.keypassword=password
#org.ops4j.pax.web.ssl.clientauthwanted=false
org.ops4j.pax.web.ssl.clientauthneeded=true

But it dont work on karaf, it don't ask for client certificate. It works on https using server-cert-authentication only.

What am i missing?


回答1:


2 changes were needed:

  1. Renamed org.ops4j.pax.web.xml file to org.ops4j.pax.web.cfg
  2. Added org.ops4j.pax.web.config.file=./etc/jetty.xml to org.ops4j.pax.web.cfg


来源:https://stackoverflow.com/questions/30908836/client-certificate-authentication-on-jetty-karaf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!