Juan,

Those log lines are generated on line 114 in this file 
https://github.com/apereo/cas/blob/c4c45442a5abef69c05fdb5fc94c88068241d8df/support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/idp/metadata/generator/FileSystemSamlIdPMetadataGenerator.java

Not sure why certs are being recreated; could be something higher up the call 
stack or a config setting.
That class makes use of a registered service.

I too run cas in docker on my local. My docker-compose.yml mounts my local 
files; cas does not recreate them.

I run version 7.0. I wonder if something changed between the versions.
You can add this logger to get more details:

<Logger name="org.apereo.cas.support.saml" level="trace">

abstract class AbstractSamlIdPMetadataLocator
has a number of trace logging lines that could help.

Ray

On Thu, 2024-10-10 at 09:37 -0700, Juan Fernando Rivera wrote:
You don't often get email from eljuanfe...@gmail.com. Learn why this is 
important<https://aka.ms/LearnAboutSenderIdentification>
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/1504f186b7793c60360a79c7c83cc2a5c92b14bd.camel%40uvic.ca.

Reply via email to