我点击了一个链接 http://lukesampson.com/post/315838839/cas-on-windows-localhost-setup-in-5-mins ,则cas服务器正常运行,登录url为http://10.1.1.26:8080/login ,验证网址为 http://10.1.1.26:8080/serviceValidate .
然后我测试如下:
- 调用http://10.1.1.26:8080/login?service=http://10.1.1.9:8081/default.aspx
- 我成功拿到服务单,比如ST-9-pJ5UDxqKIHP2zuN3JGe4-cas
- 然后我通过调用 http://10.1.1.26:8080/serviceValidate?ticket=ST-9-pJ5UDxqKIHP2zuN3JGe4-cas&service=http://10.1.1.9:8081/default.aspx 来验证服务票证,
- 不幸的是,它总是返回无效票,
为了修复它,我尝试使用 cas 1.0 验证 url,http://10.1.1.26:8080/validate?ticket=ST-9-pJ5UDxqKIHP2zuN3JGe4-cas&service=http://10.1.1.9:8081/default.aspx , 但它返回“否”。
然后我生成一个证书文件并将其放入 keystore ,然后我使用 https://10.1.1.26:8443 尝试了上述所有步骤, 然而,验证仍然失败。
我更改了cas log4j配置,打印所有调试信息,下面是日志
2012-02-21 13:18:36,371 DEBUG [org.springframework.web.servlet.DispatcherServlet
] - <DispatcherServlet with name 'cas' processing GET request for [/cas-server-w
ebapp-3.4.11/serviceValidate]>
2012-02-21 13:18:36,381 DEBUG [org.springframework.webflow.mvc.servlet.FlowHandl
erMapping] - <No flow mapping found for request with URI '/cas-server-webapp-3.4
.11/serviceValidate'>
2012-02-21 13:18:36,381 DEBUG [org.springframework.web.servlet.handler.SimpleUrl
HandlerMapping] - <Mapping [/serviceValidate] to HandlerExecutionChain with hand
ler [org.jasig.cas.web.ServiceValidateController@302a4b] and 1 interceptor>
2012-02-21 13:18:36,381 DEBUG [org.springframework.web.servlet.DispatcherServlet
] - <Last-Modified value for [/cas-server-webapp-3.4.11/serviceValidate] is: -1>
2012-02-21 13:18:36,391 INFO [org.jasig.cas.CentralAuthenticationServiceImpl] -
<ServiceTicket [ST-1-pqIeCRqcafGBE6idoCcd-cas] has expired.>
2012-02-21 13:18:36,391 INFO [com.github.inspektr.audit.support.Slf4jLoggingAudi
tTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: audit:unknown
WHAT: ST-1-pqIeCRqcafGBE6idoCcd-cas
ACTION: SERVICE_TICKET_VALIDATE_FAILED
APPLICATION: CAS
WHEN: Tue Feb 21 13:18:36 EST 2012
CLIENT IP ADDRESS: 10.1.1.9
SERVER IP ADDRESS: 10.1.1.26
=============================================================
我不明白也不知道为什么从其他帖子我看到日志有类似“将服务票据写入票据注册表,并检索服务票据”之类的内容,但我的日志中没有任何内容
最佳答案
我不是 100% 确定,因为我看不到你的配置,但日志是这样说的
<ServiceTicket [ST-1-pqIeCRqcafGBE6idoCcd-cas] has expired.>
这意味着票已经过期了。 CAS 中存在一个名为 ticketExpirationPolicies.xml
的配置文件,其中包含票证有效的时间。在我的 CAS 版本中,服务票证的有效期设置为 10000 毫秒。也许您第 1 步和第 3 步之间的时间比您文件中的过期设置长(当然),这可能与我的不同
<!-- Expiration policies -->
<bean id="serviceTicketExpirationPolicy" class="org.jasig.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy">
<!-- This argument is the number of times that a ticket can be used before its considered expired. -->
<constructor-arg
index="0"
value="1" />
<!-- This argument is the time a ticket can exist before its considered expired. -->
<constructor-arg
index="1"
value="10000" />
</bean>
<bean id="grantingTicketExpirationPolicy" class="org.jasig.cas.ticket.support.TimeoutExpirationPolicy">
<!-- This argument is the time a ticket can exist before its considered expired. -->
<constructor-arg
index="0"
value="7200000" />
</bean>
在我看来,您遵循的教程在配置设置方面并不完整。根据您尝试使用此 CAS 服务器实现的目标,您可能需要一些描述的自定义 here
关于ssl - CAS 服务票据验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9371316/