[英]WildFly 9 enable client certificate authentication
我想在 WildFly 9 服務器上運行的 Web 應用程序上啟用客戶端證書身份驗證。
為此,我使用以下元素配置了我的應用程序:
我創建了一個服務器密鑰庫,一個客戶端密鑰庫。 我從他們那里導出了一個自簽名證書,該證書包含在我的服務器信任庫中。
我的 standalone.xml 文件包含這些部分:
...
<management>
<security-realms>
<security-realm name="my-realm">
<server-identities>
<ssl>
<keystore path="server.keystore" relative-to="jboss.server.config.dir" keystore-password="password"/>
</ssl>
</server-identities>
<authentication>
<jaas name="my-domain"/>
</authentication>
</security-realm>
</security-realms>
</management>
...
<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="my-domain" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
<module-option name="usersProperties" value="${jboss.server.config.dir}/app-users.properties"/>
<module-option name="rolesProperties" value="${jboss.server.config.dir}/app-roles.properties"/>
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
</security-domains>
</subsystem>
...
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<https-listener name="https" socket-binding="https" security-realm="my-realm"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
</filters>
</subsystem>
...
我的 web.xml 文件包含這個:
...
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin Resource</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
...
<login-config>
<auth-method>CLIENT-CERT</auth-method>
<realm-name>my-realm</realm-name>
</login-config>
<security-role>
<role-name>my-role</role-name>
</security-role>
...
我的 jboss-web.xml 包含:
<security-domain>my-domain</security-domain>
我還在我的 JDK 上添加了以下參數:
-Djavax.net.debug=ssl:handshake
-Djavax.net.ssl.trustStore=[WILDFLY_HOME]\\standalone\\configuration\\server.truststore
-Djavax.net.ssl.trustStorePassword=password
然后我嘗試使用 Web 瀏覽器在 URL http://localhost:8080/my-app-web/
上訪問我的 Web 應用程序。 我被重定向到https://localhost:8443/my-app-web/
,即使瀏覽器不包含客戶端證書,我也可以訪問頁面的內容。
你能告訴我我的配置有什么問題嗎?
您的安全域中需要一個Certificate
登錄模塊。
查看此快速入門了解更多詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.