【问题标题】:CAS service ticket validate failedCAS 服务票证验证失败
【发布时间】:2022-03-21 02:45:12
【问题描述】:

我点击了一个链接http://lukesampson.com/post/315838839/cas-on-windows-localhost-setup-in-5-mins,然后cas服务器正常工作,登录url为http://10.1.1.26:8080/login,验证url为http://10.1.1.26:8080/serviceValidate

然后我像下面这样测试它:

  1. 致电http://10.1.1.26:8080/login?service=http://10.1.1.9:8081/default.aspx
  2. 我成功拿到服务票,比如ST-9-pJ5UDxqKIHP2zuN3JGe4-cas
  3. 然后我通过调用http://10.1.1.26:8080/serviceValidate?ticket=ST-9-pJ5UDxqKIHP2zuN3JGe4-cas&service=http://10.1.1.9:8081/default.aspx 来验证服务票证,
  4. 不幸的是,它总是返回无效票,

为了修复它,我尝试使用 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,但它返回“no”。

然后我生成一个证书文件并放入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
=============================================================

我不明白也不知道为什么从其他帖子中我看到日志中有类似“将服务票证写入票证注册表,并检索服务票证”的内容,但我的日志中没有任何内容

【问题讨论】:

    标签: ssl service single-sign-on cas


    【解决方案1】:

    我不能 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 中描述的一些自定义内容

    【讨论】:

    • 和这里一样的问题,显然默认的过期时间很短。我改变了,它奏效了。
    【解决方案2】:

    查看您的服务器的日期,在我的情况下,HA 服务器之间存在 10 秒的差异,并且我收到的票已过期。

    【讨论】:

    猜你喜欢
    • 2016-03-25
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 2011-07-07
    • 2018-10-20
    • 2013-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多