Question

With the following, mutual client cert, SSL (TLS) handshake works for a rest endpoint (yay!) - validated via testing and debugging: javax.net logging & wireshark. But...

1st observation: HTTPServletRequest and JAX-RS annotated SecurityContext has null Principal info

2nd observation: Tampering with the login-config.xml, containing application-policy elements, has no effect

In short, TLS works but the transfer of the cert DN to the HTTPServletRequest object in the request thread does not preventing the application from picking up on the caller's ID. Does anyone have any advice?

On JBoss 6:

deploy/jbossweb.sar/server.xml:

<Connector protocol="HTTP/1.1" debug="10"
       SSLEnabled="true"
       ...
       secure="true"
       clientAuth="true"
       sslProtocol = "TLS"
       securityDomain="java:/jaas/mydomain"
       SSLImplementation="org.jboss.net.ssl.JBossImplementation" />

deploy/jbossweb.sar/META-INF/jboss-beans.xml:

<depends>jboss.security:service=PBESecurityDomain</depends>

deploy/security-service.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server>
  <mbean code="org.jboss.security.plugins.JaasSecurityDomain"
    name="jboss.security:service=PBESecurityDomain">
    <constructor>           <arg type="java.lang.String" value="mydomain"/>
    </constructor>
    <attribute name="KeyStoreURL">${jboss.server.home.dir}/mykeystore.jks</attribute>
    <attribute name="KeyStorePass">{CLASS}org.jboss.security.plugins.FilePassword:${jboss.server.home.dir}/mykeystorepass.pbe</attribute>
    <attribute name="TrustStoreURL">${jboss.server.home.dir}/mytruststore.jks</attribute>
    <attribute name="TrustStorePass">password</attribute>
    <attribute name="Salt">abunchofrandomchars</attribute>
    <attribute name="IterationCount">13</attribute>
    <depends>jboss.security:service=JaasSecurityManager</depends>
  </mbean>
</server>

deploy/security/security-jboss-beans.xml:

<bean name="XMLLoginConfig" class="org.jboss.security.auth.login.XMLLoginConfig">
   <property name="configResource">login-config.xml</property>
</bean>
<bean name="SecurityConfig" class="org.jboss.security.plugins.SecurityConfig">
   <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
   <property name="defaultLoginConfig"><inject bean="XMLLoginConfig"/></property>
</bean>

conf/login-config.xml:

  <application-policy name="mydomain">
    <authentication>
       <login-module code="org.jboss.security.auth.spi.BaseCertLoginModule"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="securityDomain">java:/jaas/mydomain</module-option>
          <module-option name="verifier">org.jboss.security.auth.certs.AnyCertVerifier</module-option>
          <module-option name="principalClass">org.jboss.security.auth.certs.SubjectDNMapping</module-option>
       </login-module>
       <login-module code="org.jboss.security.auth.spi.UserRolesLoginModu"
          flag = "required">
          <module-option name="password-stacking">useFirstPass</module-option>
          <module-option name="usersProperties">users.properties</module-option>
          <module-option name="rolesProperties">roles.properties</module-option>
       </login-module>
    </authentication>
 </application-policy>

war/WEB-INF/jboss-web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 2.4//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
    <security-domain>java:/jaas/mydomain</security-domain>
    <context-root>/myapp</context-root>
</jboss-web>

No correct solution

OTHER TIPS

Add the special ClientLoginModule to login-context.xml to fix the null principal issue.

<login-module code="org.jboss.security.ClientLoginModule" flag="required"></login-module>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top