SSL handshake failure when RestTemplate calls self‑signed HTTPS endpoint in Grails
0 reputation · 20 Mar 2021, 15:56 UTC
When a Grails service injects the default RestTemplate to invoke an external HTTPS endpoint that presents a self‑signed certificate, the request fails with an SSL handshake error indicating the certificate chain cannot be validated. The goal is to configure the client to trust that certificate for outbound calls while avoiding unintended side effects on other components that rely on the default RestTemplate (e.g., Actuator endpoints, third‑party plugins). The documentation does not specify where a custom RestTemplate bean should be declared in a typical Grails project layout, nor whether it should be marked as primary or scoped to a specific service.
- Should the custom
RestTemplatebe declared as the primary bean or qualified with a name? - What is the recommended location (e.g.,
grails-app/conf/spring/resources.groovy, a@Configurationclass, or another file) for declaring such a bean in Grails 4+? - How can the bean be limited to only the service that needs it without affecting other HTTP clients in the application?