Search code examples
dockergradlejava-7javagradlew

How to avoid `EC parameters error` using the openjdk:7 Docker image and a Gradle wrapper?


This Dockerfile:

FROM openjdk:7

WORKDIR /restdocs/
RUN git clone https://github.com/spring-projects/spring-restdocs.git /restdocs
RUN git checkout v1.1.2.RELEASE

RUN ./gradlew build

built with docker build . -t rest-notes results in the following error: Exception in thread "main" javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC parameters error.

What can I do in the Dockerfile to avoid this and make the Gradle wrapper work?


Solution

  • I was able to get around this thanks to Erich Seifert and his commit here: https://github.com/eseifert/gral/commit/c24e08a91952a99b8c8b686a1b172335db8cdf87. Updated Dockerfile that works:

    FROM openjdk:7
    
    RUN apt-get update && apt-get install sudo
    
    # Fix the EC parameters error: (ref https://github.com/travis-ci/travis-ci/issues/8503)
    RUN sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}"/jre/lib/ext/bcprov-ext-jdk15on-158.jar && \
      sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security && \
      echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security
    
    WORKDIR /restdocs/
    RUN git clone https://github.com/spring-projects/spring-restdocs.git /restdocs
    RUN git checkout v1.1.2.RELEASE
    
    RUN ./gradlew build
    

    (Never mind that the build of that spring-restdocs branch fails - that's not related to the EC parameters error:)