jboss7-WildFly的https配置

一、HTTPS
https是在http的基礎上增長了一層加密,經常使用的加密算法是RSA,非對稱密鑰加密,原理基於大數的因式分解,須要公鑰和私鑰,公鑰對外,私鑰保密,用公鑰加密,私鑰用來解密。
我測試環境咱們用JDK自帶的工具生成,具體操做以下:
一、爲服務器生成證書:
keytool -genkey -v -alias wildfly -keyalg RSA -keystore C:\wildfly.keystore -validity 36500
password : ondfge23
您的名字與姓氏是什麼?
113.240.224.231
 
二、爲客戶端生成證書:
keytool -genkey -v -alias mykey -keyalg RSA -storetype PKCS12 -keystore C:\mykey.p12
password : onassd234
您的名字與姓氏是什麼?
113.240.224.231
 

三、讓服務器信任客戶端證書:
導出客戶端證書
keytool -export -alias mykey -keystore C:\mykey.p12 -storetype PKCS12 -storepass onassd234 -rfc -file C:\mykey.cer
導入到服務器端密鑰庫,密碼ondfge23
keytool -import -v -file C:\mykey.cer -keystore C:\wildfly.keystore
查看密鑰庫密鑰
keytool -list -keystore C:\wildfly.keystore

四、讓客戶端信任服務器證書:

keytool -keystore C:\wildfly.keystore -export -alias wildfly -file C:\wildfly.cer

生成的證書以下:
 
二、配置standalone.xml
首先指定生成的證書,配置權限級別爲後臺ManagementRealm,也可設置爲應用級別ApplicationRealm,本文之後臺爲例
 
 <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                    <ssl protocol="TLSv1">
                        <keystore path="C:\wildfly.keystore" keystore-password="ondfge23" />
                    </ssl>
                </server-identities>
                <authentication>
                    <local default-user="$local" skip-group-loading="true"/>
                    <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
                <authorization map-groups-to-roles="false">
                    <properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
                </authorization>
            </security-realm>
            <security-realm name="ApplicationRealm">
                <authentication>
                    <local default-user="$local" allowed-users="*" skip-group-loading="true"/>
                    <properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
                </authentication>
                <authorization>
                    <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
                </authorization>
            </security-realm>
        </security-realms>




配置監聽端口,指定綁定名爲https,其餘類同: java

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="${jboss.http.port:8090}"/>
        <socket-binding name="https" port="${jboss.https.port:8443}"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>



 

使監聽HTTPS配置生效,使用名爲https的綁定,安全級別爲ManagementRealm: web

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http"/>
		<https-listener name="nice" socket-binding="https" security-realm="ManagementRealm"/>
                <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-value="WildFly/10" header-name="Server"/>
                <response-header name="x-powered-by-header" header-value="Undertow/1" header-name="X-Powered-By"/>
            </filters>
        </subsystem>
  生效操做也能夠在後臺圖形界面下操做   三、驗證: 啓動服務   在瀏覽器中輸入https://127.0.0.1:9443   輸入框中出現了一把鎖,至此配置完成。 圖解WildFly 8.X配置HTTPS
相關文章
相關標籤/搜索