gradle-maven-settings-plugin icon indicating copy to clipboard operation
gradle-maven-settings-plugin copied to clipboard

Unable to decrypt local Maven settings credentials.

Open gusdevops opened this issue 7 years ago • 7 comments

Everything works with maven, regarding that my settings and security files are configured properly, but when I ran gradle

                    .....
  at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: Unable to decrypt local Maven settings credentials.
        at net.linguica.gradle.maven.settings.LocalMavenSettingsLoader.decryptCredentials(LocalMavenSettingsLoader.java:102)
        at net.linguica.gradle.maven.settings.LocalMavenSettingsLoader.loadSettings(LocalMavenSettingsLoader.java:66)
        at net.linguica.gradle.maven.settings.LocalMavenSettingsLoader$loadSettings.call(Unknown Source)
        at net.linguica.gradle.maven.settings.MavenSettingsPlugin.loadSettings(MavenSettingsPlugin.groovy:69)
        at net.linguica.gradle.maven.settings.MavenSettingsPlugin.this$2$loadSettings(MavenSettingsPlugin.groovy)
        at net.linguica.gradle.maven.settings.MavenSettingsPlugin$_apply_closure1.doCall(MavenSettingsPlugin.groovy:58)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy23.afterEvaluate(Unknown Source)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:75)
        ... 76 more
Caused by: org.sonatype.plexus.components.cipher.PlexusCipherException: javax.crypto.BadPaddingException: Given final block not properly padded
        at org.sonatype.plexus.components.cipher.PBECipher.decrypt64(PBECipher.java:193)
        at org.sonatype.plexus.components.cipher.DefaultPlexusCipher.decrypt(DefaultPlexusCipher.java:72)
        at org.sonatype.plexus.components.cipher.DefaultPlexusCipher.decryptDecorated(DefaultPlexusCipher.java:86)
        at net.linguica.gradle.maven.settings.LocalMavenSettingsLoader.decryptCredentials(LocalMavenSettingsLoader.java:87)
        ... 94 more
Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:989)
        at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:845)
        at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
        at org.sonatype.plexus.components.cipher.PBECipher.decrypt64(PBECipher.java:185)
        ... 97 more

end

####Gradle version


Gradle 4.0.1

Build time: 2017-07-07 14:02:41 UTC Revision: 38e5dc0f772daecca1d2681885d3d85414eb6826

Groovy: 2.4.11 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.8.0_141 (Oracle Corporation 25.141-b15) OS: Linux 4.11.9-1-ARCH amd64

####Java version openjdk version "1.8.0_141" OpenJDK Runtime Environment (build 1.8.0_141-b15) OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)

####uname -a Linux phenx 4.11.9-1-ARCH #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017 x86_64 GNU/Linux ArchLinux Os ..

gusdevops avatar Aug 21 '17 17:08 gusdevops

@gusdevops Having this same problem, did you find a solution?

kenahoo avatar Jul 11 '18 21:07 kenahoo

I figured out my problem - in my ~/.m2/settings.xml I was using encrypted credentials that apparently Gradle couldn't deal with. I deleted those and put cleartext credentials into a new ~/.gradle/gradle.properties file, and stuff started working.

I don't feel too bad about converting from "encrypted" to cleartext, because it seems like basically just obfuscation-level encryption anyway, since its secret key isn't so secret.

kenahoo avatar Jul 12 '18 15:07 kenahoo

I got this error as well - but the credentials are not encrypted (tho they look like). My settings.xml is (relevant values changes):

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
    <server>
        <id>company</id>
        <username>company-dev</username>
        <password>dsS5AdfsgdTsdf9aF42P</password>
    </server>
</servers>
<mirrors/>
<proxies/>
<profiles>
    <profile>
        <id>nexus</id>
        <repositories>
            <repository>
                <id>company</id>
                <url>https://nexus.companyname.com/repository/company/</url>
            </repository>
        </repositories>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

Amy idea?

patmuk avatar Aug 20 '18 20:08 patmuk

I found this issue too and in my case in the context of running a CI workflow with github actions who creates automatically a ~/.m2/settings.xml file that cannot be decrypted by this plugin, maybe there should be an option to disable the decryption for cases when the password is not encrypted or more simply just detect if there is not a ~/.m2/settings-security.xml file and in that case do not try to decrypt the password.

iemejia avatar Apr 17 '20 20:04 iemejia

I have exactly the same issue, @iemejia

have you found a solution in the meanwhile?

elect86 avatar Sep 02 '20 20:09 elect86

@elect86 If your question is concretely about github actions I ended up just removing their settings file since I really did not need it. https://github.com/iemejia/ci-beam/blob/1ee1e3b621acdc967431429566767b760fbca9ca/.github/workflows/spark-nexmark.yml#L20-L24

iemejia avatar Sep 08 '20 07:09 iemejia

Yep, it is (was), thanks!

elect86 avatar Sep 08 '20 08:09 elect86