client-certificate authentication on jetty (karaf)

1.4k views Asked by At

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

There are 1 answers

1
HimanshuR On BEST ANSWER

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