I don’t know why your problem occurs by accident, but at least one of the ways to resolve it is to configure SAMLContextProviderLB instead of your current SAMLContextProviderImpl .
SAMLContextProviderLB usually used to tell Spring SAML public about the public URLs used on the reverse proxy or load balancer, but in this case you can use Spring SAML to think that it uses HTTPS. Details can be found in Chapter 10.1 Advanced Configuration of the Spring SAML manual.
You must also ensure that the entityBaseURL property is set entityBaseURL for your MetadataGenerator bean, as the generated metadata will depend on whether you made the first request to your application using http or https. Again, all of this is documented .
Vladimír Schäfer
source share