title: CAS between two different servers
body: <p>I have installed a CAS server with a public domain and it works correctly.</p>
  
  <p>Now I want to use my other public domain with different services with CAS authentication but, after login in CAS, when I redirect to these services, PHPCas tell me "Authentication failed, you were not authenticated"</p>
  
  <p>I have been searching for a long time and I couldn't find any solution. What I need is to keep the CAS session between two servers.</p>
  
  <p>The configuration of PHPCas authentication is:</p>
  
  <pre><code>phpCAS::client(CAS_VERSION_2_0,'example.com', 8443,'/cas', TRUE);
  </code></pre>
  
  <p>The url is this: <a href="http://client.com/portal.php?ticket=ST-" rel="nofollow noreferrer">http://client.com/portal.php?ticket=ST-</a>.....
  so the ticket is granted (in CAS server log tells "ticcket granted"), why is failiing the authentication?</p>
  
  <p>Here you have the log of phpCAS:</p>
  
  <pre><code>D4B6 .START (2018-03-15 11:57:13) phpCAS-1.3.5+ ****************** [CAS.php:468]
  D4B6 .=&gt; phpCAS::client('2.0', 'XX.com', 8443, '/cas') [portal.php:10]
  D4B6 .|    =&gt; CAS_Client::__construct('2.0', false, 'XX.com', 8443, '/cas', true) [CAS.php:360]
  D4B6 .|    |    Starting a new session okutpm09o0akdi2bisd1q9ivg5 [Client.php:932]
  D4B6 .|    |    Session is not authenticated [Client.php:938]
  D4B6 .|    &lt;= ''
  D4B6 .&lt;= ''
  D4B6 .=&gt; phpCAS::setNoCasServerValidation() [portal.php:13]
  D4B6 .|    You have configured no validation of the legitimacy of the cas server. This is not recommended for production use. [CAS.php:1644]
  D4B6 .&lt;= ''
  D4B6 .=&gt; phpCAS::forceAuthentication() [portal.php:16]
  D4B6 .|    =&gt; CAS_Client::forceAuthentication() [CAS.php:1098]
  D4B6 .|    |    =&gt; CAS_Client::isAuthenticated() [Client.php:1280]
  D4B6 .|    |    |    =&gt; CAS_Client::_wasPreviouslyAuthenticated() [Client.php:1393]
  D4B6 .|    |    |    |    no user found [Client.php:1635]
  D4B6 .|    |    |    &lt;= false
  D4B6 .|    |    |    no ticket found [Client.php:1494]
  D4B6 .|    |    &lt;= false
  D4B6 .|    |    =&gt; CAS_Client::redirectToCas(false) [Client.php:1289]
  D4B6 .|    |    |    =&gt; CAS_Client::getServerLoginURL(false, false) [Client.php:1656]
  D4B6 .|    |    |    |    =&gt; CAS_Client::getURL() [Client.php:342]
  D4B6 .|    |    |    |    |    Final URI: https://www.XX.com/newlogin/v1/portal.php [Client.php:3549]
  D4B6 .|    |    |    |    &lt;= 'https://www.XX.com/newlogin/v1/portal.php'
  D4B6 .|    |    |    &lt;= 'https://XX.com:8443/cas/login?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php'
  D4B6 .|    |    |    Redirect to : https://XX.com:8443/cas/login?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php [Client.php:1663]
  D4B6 .|    |    |    exit()
  D4B6 .|    |    |    -
  D4B6 .|    |    -
  D4B6 .|    -
  B117 .START (2018-03-15 11:57:15) phpCAS-1.3.5+ ****************** [CAS.php:468]
  B117 .=&gt; phpCAS::client('2.0', 'XX.com', 8443, '/cas') [portal.php:10]
  B117 .|    =&gt; CAS_Client::__construct('2.0', false, 'XX.com', 8443, '/cas', true) [CAS.php:360]
  B117 .|    |    Starting a new session okutpm09o0akdi2bisd1q9ivg5 [Client.php:932]
  B117 .|    |    Session is not authenticated [Client.php:938]
  B117 .|    |    Ticket 'ST-43-bcpN1lrL0uxok07f9Xf4-cas' found [Client.php:1020]
  B117 .|    &lt;= ''
  B117 .&lt;= ''
  B117 .=&gt; phpCAS::setNoCasServerValidation() [portal.php:13]
  B117 .|    You have configured no validation of the legitimacy of the cas server. This is not recommended for production use. [CAS.php:1644]
  B117 .&lt;= ''
  B117 .=&gt; phpCAS::forceAuthentication() [portal.php:16]
  B117 .|    =&gt; CAS_Client::forceAuthentication() [CAS.php:1098]
  B117 .|    |    =&gt; CAS_Client::isAuthenticated() [Client.php:1280]
  B117 .|    |    |    =&gt; CAS_Client::_wasPreviouslyAuthenticated() [Client.php:1393]
  B117 .|    |    |    |    no user found [Client.php:1635]
  B117 .|    |    |    &lt;= false
  B117 .|    |    |    CAS 2.0 ticket `ST-43-bcpN1lrL0uxok07f9Xf4-cas' is present [Client.php:1447]
  B117 .|    |    |    =&gt; CAS_Client::validateCAS20('', NULL, NULL, false) [Client.php:1450]
  B117 .|    |    |    |     [Client.php:3170]
  B117 .|    |    |    |    =&gt; CAS_Client::getServerServiceValidateURL() [Client.php:3177]
  B117 .|    |    |    |    |    =&gt; CAS_Client::getURL() [Client.php:453]
  B117 .|    |    |    |    |    |    Final URI: https://www.XX.com/newlogin/v1/portal.php [Client.php:3549]
  B117 .|    |    |    |    |    &lt;= 'https://www.XX.com/newlogin/v1/portal.php'
  B117 .|    |    |    |    &lt;= 'https://XX.com:8443/cas/serviceValidate?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php'
  B117 .|    |    |    |    =&gt; CAS_Client::_readURL('https://XX.com:8443/cas/serviceValidate?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php&amp;ticket=ST-43-bcpN1lrL0uxok07f9Xf4-cas', NULL, NULL, NULL) [Client.php:3192]
  B117 .|    |    |    |    |    =&gt; CAS_Request_CurlRequest::sendRequest() [AbstractRequest.php:242]
  B117 .|    |    |    |    |    |    curl_exec() failed [CurlRequest.php:77]
  B117 .|    |    |    |    |    &lt;= false
  B117 .|    |    |    |    &lt;= false
  B117 .|    |    |    |    could not open URL 'https://XX.com:8443/cas/serviceValidate?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php&amp;ticket=ST-43-bcpN1lrL0uxok07f9Xf4-cas' to validate (CURL error #7: Failed to connect to XX.com port 8443: Connection refused) [Client.php:3195]
  B117 .|    |    |    |    =&gt; CAS_AuthenticationException::__construct(CAS_Client, 'Ticket not validated', 'https://XX.com:8443/cas/serviceValidate?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php&amp;ticket=ST-43-bcpN1lrL0uxok07f9Xf4-cas', true) [Client.php:3199]
  B117 .|    |    |    |    |    =&gt; CAS_Client::getURL() [AuthenticationException.php:77]
  B117 .|    |    |    |    |    &lt;= 'https://www.XX.com/newlogin/v1/portal.php'
  B117 .|    |    |    |    |    CAS URL: https://XX.com:8443/cas/serviceValidate?service=https%3A%2F%2Fwww.XX.com%2Fnewlogin%2Fv1%2Fportal.php&amp;ticket=ST-43-bcpN1lrL0uxok07f9Xf4-cas [AuthenticationException.php:80]
  B117 .|    |    |    |    |    Authentication failure: Ticket not validated [AuthenticationException.php:81]
  B117 .|    |    |    |    |    Reason: no response from the CAS server [AuthenticationException.php:83]
  B117 .|    |    |    |    |    exit()
  B117 .|    |    |    |    |    -
  B117 .|    |    |    |    -
  B117 .|    |    |    -
  B117 .|    |    -
  B117 .|    -
  </code></pre>
  
  <p>I have changed the real URL to XX, just for privacy :)
  What can I do? Thanks!</p>