# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 127.0.0.1 www.mycas.com
2.2 導出證書:web
方便複製:keytool -import -keystore "C:\Program Files\Java\jdk1.8.0_40\jre\lib\securit
y\cacerts" -file E://cas/mykey.cer -alias mykey
這裏輸入的密碼:changeit
2.4 修改tomcat配置
打開tomcat的conf目錄下server.xml,找到spring
1 <!-- 2 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" 3 maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 4 clientAuth="false" sslProtocol="TLS" /> 5 -->
將註釋打開,並改成apache
1 <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" 2 maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 3 clientAuth="false" sslProtocol="TLS" 4 keystoreFile="E:/cas/mykey.keystore" keystorePass="123456" />
其中keystoreFile是生成證書的路徑,keystorePass是證書的密碼tomcat
1 <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" 2 p:httpClient-ref="httpClient" />
添加參數requireSecure爲false,以下:cookie
1 <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" 2 p:httpClient-ref="httpClient" 3 p:requireSecure="false" />
4.2 找到WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml下app
1 <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" 2 p:cookieSecure="true" 3 p:cookieMaxAge="-1" 4 p:cookieName="CASTGC" 5 p:cookiePath="/cas" />
將cookieSecure改成false,以下:webapp
1 <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" 2 p:cookieSecure="false" 3 p:cookieMaxAge="-1" 4 p:cookieName="CASTGC" 5 p:cookiePath="/cas" />
4.3 找到WEB-INF\spring-configuration\warnCookieGenerator.xml下工具
1 <bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" 2 p:cookieSecure="true" 3 p:cookieMaxAge="-1" 4 p:cookieName="CASPRIVACY" 5 p:cookiePath="/cas" />
將cookieSecure改成false,以下學習
1 <bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator" 2 p:cookieSecure="false" 3 p:cookieMaxAge="-1" 4 p:cookieName="CASPRIVACY" 5 p:cookiePath="/cas" />
4.4 找到tomcat的conf目錄下server.xml
把以前打開的註釋關閉。測試以下:測試
方便複製:http://www.mycas.com:8088/cas-server-webapp-3.5.2/login
這裏我把tomcat的端口改爲了8088。