Can't fetch plugins from repositories with scala's sbt

Viewed 1418

I try to compile/build scala project with sbt, there are two plugins mentioned in project/plugins.sbt:

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.17")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.4")

Error while importing sbt project:

[error] sbt.librarymanagement.ResolveException: download failed: 
com.typesafe.play#sbt-plugin;2.6.17!sbt-plugin.jar
[error] download failed: com.typesafe.sbt#sbt-native-packager;1.3.4!sbt-native- 
packager.jar

Seems that problem in certificates for repositories, so i manually take each certificate and add it to my keystore with a command (i use ubuntu):

keytool -import -alias "artifact server2" -keystore /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts -file _.bintray.com

But it doesn't help.

Update: i solved my problem by manual adding all certificates (end and intermediate) from repo's hosts to local keystore.

1 Answers

This issue had me almost ready to throw my macbook out the window.

On my mac, the java cacerts is located here:

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/security/cacerts

To get ahold of the required certificate for sbt-native-packager I used this (which I stole from someone, and now I can't find the attribution):

echo -n | openssl s_client -connect repo.scala-sbt.org:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/scala-sbt.cert

Then to add it to the java trust store, I used Stanislav's solution above:

sudo keytool -import -alias "scala-sbt server" -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/security/cacerts -file /tmp/scala-sbt.cert

Remember that the default password for the cacerts file is changeit

And then the next time I ran sbt the plugin downloaded and I almost wept tears of joy.

Related