Search code examples
javamavensslclojureleiningen

lein ring uberjar : PKIX path building failed?


I am not able to run "lein ring uberjar" from my local machine. I get the following errors:

Could not find artifact ring-server:ring-server:jar:0.5.0 in central (https://repo1.maven.org/maven2/)
Could not transfer artifact ring-server:ring-server:jar:0.5.0 from/to clojars (https://repo.clojars.org/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not transfer artifact ring-server:ring-server:pom:0.5.0 from/to clojars (https://repo.clojars.org/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not transfer artifact ring:ring:pom:1.6.1 from/to clojars (https://repo.clojars.org/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

I think this is something todo with ssl, but i'm not sure how to fix it. Is there away to reset the certificates?

This is what my project.clj looks like:

(defproject app
  :dependencies [
                 [org.clojure/clojure "1.10.0"]
                 [org.clojure/tools.logging "0.4.0"]
                 [org.clojure/tools.cli "0.3.5"]
                 [org.clojure/data.json "0.2.6"]
                 [clj-http "3.9.1"]
                 [clj-time "0.14.2"]
                 [mysql/mysql-connector-java "5.1.38"]
                 [org.slf4j/slf4j-log4j12 "1.7.25"]
                 [log4j/log4j "1.2.17" :exclusions [javax.mail/mail
                                                    javax.jms/jms
                                                    com.sun.jmdk/jmxtools
                                                    com.sun.jmx/jmxri]]
                 [metosin/compojure-api "1.1.11"]
                 [metosin/ring-swagger "0.26.1"]
                 [compojure "1.6.0"]
                 [cheshire "5.8.0"]
                 [ring "1.6.3"]
                 [ring/ring-json "0.4.0"]
                 [ring-logger "0.7.7"]
                 [environ "1.1.0"]
                 [korma "0.4.3"]
                 [blackwater "0.0.9"]
                 [prismatic/schema "1.1.7"]
                 [siili/humanize "0.1.1"]
                 [ring-cors "0.1.12"]
                 [commons-io "2.0"]
                 [buddy/buddy-sign "3.0.0"]
                 [byte-transforms "0.1.4"]
                 ]

  :ring {:handler app.api.handler/app}

  :source-paths ["src"]

  :resource-paths ["resources"]

  :test-paths ["test/unit"
               "test/features"]

  :profiles {:default [:local]
             :uberjar {:aot :all}
             :local   {:cucumber-feature-paths ["test/features"]
                       :plugins                [
                                                [lein-ring "0.12.1"]
                                                [com.siili/lein-cucumber "1.0.7"]
                                                [lein-cloverage "1.0.10"]
                                                [lein-kibit "0.1.6"]
                                                [lein-cloverage "1.0.10"]
                                                [lein-try "0.4.3"]
                                                [nightlight/lein-nightlight "1.0.0"]
                                                [jonase/eastwood "0.2.3"]
                                                [cider/cider-nrepl "0.16.0"]
                                                ]
                       }
             }
  )

Solution

  • I think my JVM's CA settings got mucked up, I was able to resolve this issue by:

    1. Downloading the missing .crt file via browser.
    2. Adding .crt file to key store. keytool -import -trustcacerts -file [.crt file path] -alias [alias] -keystore $JAVA_HOME/lib/security/cacerts
    3. Checking .crt file was definitely added to the key store keytool -list -keystore $JAVA_HOME/lib/security/cacerts
    4. Reran lein ring uberjar