Repository navigation
ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target #17012
Unanswered
makushatnik
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I just started to work with Keycloak & it immediately has turned into nightmare!
I installed Keycloak, spinned up an Spring Boot app, tied everything together & it works.
I'm trying to deploy similarly on the server in separate containers. Keycloak 20.0.3.
I generate the certificate as described here:
Containers
I make my custom_keycloak image:
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_DB=postgres
WORKDIR /opt/keycloak
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=alfavit" -alias server -ext "SAN:c=DNS:alfavit01,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:20.0.3
COPY --from=builder /opt/keycloak/ /opt/keycloak/
COPY realm-export.json /opt/jboss/keycloak/imports/realm-export.json
ENV KC_DB=postgres
ENV KC_DB_URL=jdbc:postgresql://postgres:5432/keycloak
ENV KC_DB_USERNAME=keycloak
ENV KC_DB_PASSWORD=postgres
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]```
I launch Keycloak in prod mode, download the certificate in the Chrome browser, as described here:
Stackoverflow
the crt or deb file with the certificate is downloaded.
Now I need to add this certificate to cacerts in the Spring container, right?
keytool -import -alias example -keystore /etc/ssl/certs/java/cacerts -file server.pem (or crt/der file)
The problem is that the cacerts file is present when installing java locally, it isn't in the openjdk:17 image.
Until the 3rd step, locally, Spring Boot didn't recognize the tokens received from Keycloak.
Q: What needs to be done to make Spring Boot recognize Keycloak tokens?
Now I have a mistake in my Spring Boot app using token from Keycloak:
ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
How to fix it?
All reactions