Home > Blockchain >  Getting "PKIX path building failed" error while running my selenium client code inside doc
Getting "PKIX path building failed" error while running my selenium client code inside doc

Time:10-16

I am connecting to selenium grid to run my selenium tests. The client code is dockerized using the below dockerfile

FROM gradle:7.2.0-jdk8
COPY src /home/app/src
COPY build.gradle /home/app
COPY settings.gradle /home/app
COPY Dockerfile /home/app
ADD ssl.crt /usr/local/share/ca-certificates/ssl.crt
RUN update-ca-certificates
WORKDIR /home/app
EXPOSE 80
ENTRYPOINT ["gradle", "--info", "clean", "test","-Denvironment=stagging","-Dtags=envr:stagging","-Dcucumber.options=--tags @envr=stagging" ]

Now When I run the container I get error "Grid URL could not be reached: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

Now if I run the same gradle command(EntryPoint) from my java workspace it all works fine. So probably some networking issue which I am not able to understand.

Queestions:

  1. Why is it not connecting the hub(Selenium grid)?
  2. Do I need chromeDriver,Xvnc etc in the client image to run my tests?

CodePudding user response:

I had to convert the crt file to der format first

openssl x509 -in ssl.crt -out ssl.pem
openssl x509 -in ssl.pem -inform pem -out ssl.der -outform der

Then,I got passed the issue through by adding the following lines in my dockerfile. Additionally I had to expose port 40000 as my zalenium containers are running on port 40000

FROM gradle:7.2.0-jdk8


COPY src /home/app/src
COPY build.gradle /home/app
COPY settings.gradle /home/app
COPY Dockerfile /home/app
ADD ssl.der /home/app/ssl.der
RUN \
keytool -importcert -alias startssl -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -file /home/app/ssl.der -noprompt
WORKDIR /home/app
EXPOSE 40000
ENTRYPOINT ["gradle", "--info", "clean", "test","-Denvironment=stagging","-Dtags=envr:stagging","-Dcucumber.options=--tags @envr=stagging" ]
  • Related