Thanks for answering, with your help I've been able to pinpoint the exact 
cause of my issues with Liferay. 
BUT copying the keys prior to start CAS is not working, you see, I'm 
developing using Docker containers, and before starting the image I copy a 
lot of files, including the keys, and I've found these messages in CAS log 
(most relevant in yellow). The main reason is that the testing environment 
is a Docker container. It's CAS 6.6.

-------8<------
[org.apereo.cas.support.saml.idp.metadata.generator.BaseSamlIdPMetadataGenerator]
 
- <Preparing to generate metadata for entity id [ENTITY]>
2024-10-10 16:14:52 2024-10-10 10:14:52,315 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.BaseSamlIdPMetadataGenerator]
 
- <Creating self-signed certificate for signing...>
2024-10-10 16:14:52 2024-10-10 10:14:52,316 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.FileSystemSamlIdPMetadataGenerator]
 
- <Certificate file [/etc/cas/saml/idp-signing.crt] already exists, and 
will be deleted>
2024-10-10 16:14:52 2024-10-10 10:14:52,422 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.FileSystemSamlIdPMetadataGenerator]
 
- <Key file [/etc/cas/saml/idp-signing.key] already exists, and will be 
deleted>
2024-10-10 16:14:54 2024-10-10 10:14:54,032 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.BaseSamlIdPMetadataGenerator]
 
- <Creating self-signed certificate for encryption...>
2024-10-10 16:14:54 2024-10-10 10:14:54,033 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.FileSystemSamlIdPMetadataGenerator]
 
- <Certificate file [/etc/cas/saml/idp-encryption.crt] already exists, and 
will be deleted>
2024-10-10 16:14:54 2024-10-10 10:14:54,033 INFO 
[org.apereo.cas.support.saml.idp.metadata.generator.FileSystemSamlIdPMetadataGenerator]
 
- <Key file [/etc/cas/saml/idp-encryption.key] already exists, and will be 
deleted>
------->8------

So, every time the container starts, because at 1800 it's stopped every 
day, even when the keys are copied to the image prior to start CAS, they 
are deleted and re-created by CAS. Confirmed when inspecting the files in 
the container. And the prior idp-metadata imported by Liferay is not valid 
anymore. Until re-imported.

Is there a property to override this behaviour?

So far, the workaround is re-creating the idp-metadata using CAS endpoint 
"/idp/metadata", and re-importing it in Liferay, it takes no longer than 2 
minutes, but the client is worried that in the production environment, 
where is known that docker container restart with no reason, this can be 
troublesome.

Thanks again.
On Thursday, October 10, 2024 at 10:01:59 AM UTC-6 Ray Bon wrote:

> Juan,
>
> Cas will create IdP metadata and certificates if they do not exist (save 
> them for future deploys). For your dev setup, you will have to add them to 
> the directory before cas starts; either COPY into your container image or 
> mount the volume when the container starts. If you use a traditional 
> deployment (jenkins etc) let the tool install them.
>
> Ray
>
> On Wed, 2024-10-09 at 17:53 -0700, Juan Fernando Rivera wrote:
>
> You don't often get email from eljua...@gmail.com. Learn why this is 
> important <https://aka.ms/LearnAboutSenderIdentification>
>
> Hi, reading your post I think the problem is that the files in 
> "/etc/cas/saml" (idp-encryption.*, idp-signing.*) are created every time 
> CAS is restarted. I know that in a production environment this won't be an 
> issue, but right now it is. 
>
> Is there a way to prevent these files to recreating everytime my CAS 
> container is restarted?
>
> Thanks in advance.
>
> On Monday, October 7, 2024 at 12:43:28 PM UTC-6 Ray Bon wrote:
>
> Juan,
>
> Can you clarify your description of the certificates and metadata?
>
> Liferay will create SP metadata with encryption certificate (and maybe 
> signing too); you will create IdP metadata (cas will do this if it does not 
> exist) with signing and encryption certificates. You point cas config at 
> the certificates that you (or cas) created. Liferay SP certificates should 
> be different from your IdP certificates.
>
> Ray
>
> On Sun, 2024-10-06 at 14:53 -0700, Juan Fernando Rivera wrote:
>
> You don't often get email from eljua...@gmail.com.Learn why this is 
> important <https://aka.ms/LearnAboutSenderIdentification>
>
> Hi, I'm following the guidelines of configuring a SAML service in CAS, but 
> I'm having trouble connecting to Liferay portal. 
>
> In Liferay were created the certificates and imported in the idp-metadata 
> file which was sent back to Liferay and imported. Everything runs fine, BUT 
> after entering the credentials in CAS, this error (or similar) appears in 
> Liferay logs:
>
> 2024-10-04 21:51:11.830 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][ApacheSantuarioSignatureValidationProviderImpl:65]
>  
> Validating signature with signature algorithm URI:
> http://www.w3.org/2001/04/xmldsig-more#rsa-sha256
> 2024-10-04 21:51:11.830 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][ApacheSantuarioSignatureValidationProviderImpl:66]
>  
> Validation credential key algorithm 'RSA', key instance class 
> 'sun.security.rsa.RSAPublicKeyImpl'
> 2024-10-04 21:51:11.831 WARN 
>  [http-nio-0.0.0.0-9444-exec-4][XMLSignature:891] Signature verification 
> failed.
> 2024-10-04 21:51:11.831 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][ApacheSantuarioSignatureValidationProviderImpl:78]
>  
> Signature cryptographic validation not successful
> 2024-10-04 21:51:11.831 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][BaseSignatureTrustEngine:244] Signature 
> validation using candidate validation credential failed
> org.opensaml.xmlsec.signature.support.SignatureException: Signature 
> cryptographic validation not successful
> .....
> 2024-10-04 21:51:11.832 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][ExplicitKeySignatureTrustEngine:124] Failed 
> to verify signature using either KeyInfo-derived or directly trusted 
> credentials
> 2024-10-04 21:51:11.833 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][SAMLProtocolMessageXMLSignatureSecurityHandler:142]
>  
> Message Handler:  Validation of protocol message signature failed for 
> context issuer 'ENTITY_ID', message type: 
> {urn:oasis:names:tc:SAML:2.0:protocol}Response
> 2024-10-04 21:51:11.833 DEBUG 
> [http-nio-0.0.0.0-9444-exec-4][WebSsoProfileImpl:210] Validation of 
> protocol message signature failed
> .....
>
> According to the Liferay admin, the main issue may come from CAS, because 
> is not using the right key to generate the values in the SAML Response. 
> Other reason may be encryption or signature.
> I have tried both encryption and signature options in service.json file, 
> but no avail, the errors are th same.
> How can I verify this suspicions of Liferay admin? how can I force CAS to 
> use a certain private key to generate the data in SAML response?
>
> Thanks in advance.
>
>
>

-- 
- Website: https://apereo.github.io/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/8aafad70-a010-44c5-a376-0c1928b12af8n%40apereo.org.

Reply via email to