maven release -> peer not authenticated
Solution 1
Since version 3.0.5 Maven checks the SSL certificate on https connections. You can temporarily fix this by adding the command line parameters
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
Installing the SSL certificate into your JRE should permanently fix the issue.
Official documentation: http://maven.apache.org/wagon/wagon-providers/wagon-http/
Solution 2
Step 1. Download the certificate in DER format *.cer (/X.509 .cert) file to your local dir
(You can do this from your browser; For Chrome Click on the Lock symbol, Show Ceritficate --> Copy to File)
Step 2. Import it to Java trust store
\Program_Files\Java\jdk1.6.0_45\jre\lib\security>%JAVA_HOME%\jre\bin\keytool -v -alias mavensrv -import -file d:\temp\apacher.cer -keystore trust.jks
Step 3. Give the path to maven as environment variables
set MAVEN_OPTS=-Xmx512m -Djavax.net.ssl.trustStore=%JAVA_HOME%/jre/lib/security/trust.jks -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.keyStore=%JAVA_HOME%/jre/lib/security/trust.jks -Djavax.net.ssl.keyStoreType=jks -Djavax.net.ssl.keyStorePassword=changeit
Solution 3
Your entry in settings.xml
is for a server id of localhost
but you are accessing repositories with id(s) of byterendition-releases
and byterendition-snapshots
.
This means that maven won't recogonize and associate the credentials with these two servers, because they have different "identities". You will need settings.xml entries for byterendition-releases
and byterendition-snapshots
.
Now if you added an entry like
<server>
<id>byterendition-releases</id>
<username>user</username>
<password>password</password>
</server>
Then maven would meet the https authentication challenge to byterendition-releases
with a username of user
and a password of password
, because it has a server credential entry for byterendition-releases
.
You'll also have to add in an additional entry for byterendition-snapshots
, or set it to have the same server id as byterendition-releases
.
--- Edited to keep up with the updated question ---
You are reaching for your repository with a localhost
URL. While this might work if your repository is really on the same host machine, there are lots of reasons why it might not work.
- The SVN repository is on a remote SVN server, so this will fail when developing elsewhere than the remote server.
- The HTTP server is not configured to resolve localhost exactly the same way that it might resolve an external request.
Either way, ditch localhost. If you can't get a stable DNS name for the machine, even putting in an IP address is a better choice. If your SVN server is on DHCP, then invest the time into getting DynamicDNS working (but really, you should get a static IP for a server if you can).
Solution 4
https://github.com/escline/InstallCert provides the necessary tools and provides a step by step instruction on how to import a remote certificate into the system-wide certificate store.
Solution 5
I found that the Java version can make a difference here.
With Maven 3.0.5 I was getting this error with Java 6, but switching to Java 7 (or newer) resolved it for me.
Erik Stens
Updated on July 09, 2022Comments
-
Erik Stens almost 2 years
I'm experimenting a bit with releasing my software (I've never done this before) and so far I've been able to execute mvn release:prepare. As I'm executing release:perform I get the following error:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plug in:2.7:deploy (default-deploy) on project img2stl: Failed to deploy artifacts: C ould not transfer artifact nl.byterendition:img2stl:jar:0.9 from/to byterenditio n-releases (https://localhost:443/svn/repo/releases): peer not authenticated -> [Help 1]
I've set up a local password protected svn repository at localhost:443, so I added the following to my settings.xml in my .m2 folder
EDITED TO INCLUDE Edwin Buck's answer:
<?xml version="1.0" encoding="UTF-8"?> <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 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>byterendition-releases</id> <username>username</username> <password>password</password> </server> <server> <id>byterendition-snapshots</id> <username>username</username> <password>password</password> </server> </servers> </settings>
This is the useful section of my pom:
<distributionManagement> <repository> <id>byterendition-releases</id> <url>https://localhost:443/svn/repo/releases</url> </repository> <snapshotRepository> <id>byterendition-snapshots</id> <url>https://localhost:443/svn/repo/snapshots</url> </snapshotRepository> </distributionManagement>
How can I get maven to access the svn repository?
Ok, as Edwin Buck suggested I shouldn't use localhost, but since I haven't been able to get it to work otherwise I thought I'd try this using a remote SVN server I use for work. Now I get a different error:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plug in:2.7:deploy (default-deploy) on project img2stl: Failed to deploy artifacts: C ould not transfer artifact nl.byterendition:img2stl:jar:0.9.5 from/to byterendit ion-releases (https://svn.science.ru.nl/repos/estens/releases/): Failed to trans fer file: https://svn.science.ru.nl/repos/estens/releases/nl/byterendition/img2s tl/0.9.5/img2stl-0.9.5.jar. Return code is: 409, ReasonPhrase: Conflict. -> [Hel p 1]
Again I can access this repo from Eclipse. Does anyone know what I'm doing wrong?
-
Erik Stens about 11 yearsThanks, I did that, but it didn't help, I still get the exact same error. I edited the post to reflect the updated settings.xml. How can I check if maven actually uses the settings.xml file to see if maybe that is the problem?
-
Edwin Buck about 11 yearsTry running maven with the
-X
option will put out a lot of data which can be useful in determining whether you are connecting to the right server, with or without credentials. Finally, if you have access to the server, check to see if you fail authentication on the back end, as there might be other networking issues at play here. -
Erik Stens about 11 yearsHm, seems maven is using the correct file: [DEBUG] Reading user settings from C:\Users\username\.m2\settings.xml
-
Erik Stens about 11 yearsI added the repo location in Eclipse and there I could access it using the same credentials I put into the settings.xml file
-
Edwin Buck about 11 yearsOdds are that the SSL cert is an issue. Maybe it has a lot to do with attempting to reach you machine as
localhost
. Odds are your cert is signed for you machine's hostname, which probably isn't localhost. If on a Linux-ish system look in /var/log/secure for failures, they are often "descriptive enough" to find the next part of the solution. -
j kan over 10 yearsThis started happening for me after updating to Mavericks on MacOSX, and this turned out to be the solution: stackoverflow.com/questions/4428901/…
-
gerben over 10 yearsThe Maven release plugin does not propagate system properties to the maven release build. Thus one needs to add
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <configuration> <arguments>-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true</arguments> </configuration> </plugin>
to ones settings.xml see notatube.blogspot.nl -
taringamberini about 10 yearsI had done steps 1 and 2 before having red this answer and it had solved some
ReasonPhrase:Forbidden
andpeer not authenticated
problems. Next thepeer not authenticated
happened again and adding-Djavax.net.ssl.trustStore=%JRE_HOME%\lib\security\cacerts -Djavax.net.ssl.trustStorePassword=changeit
didn't solved it. Thanks to your step 3 I've added-Djavax.net.ssl.keyStore=%JRE_HOME%\lib\security\cacerts -Djavax.net.ssl.keyStorePassword=changeit
too solving my problems. (WhereJAVA_HOME=C:\Programmi\java\jdk1.7.0_25
andJRE_HOME=%JAVA_HOME%\jre
) -
hunyadym over 9 yearsIt also solved my problem when Gradle couldn't reach the maven repo.
-
user_mda about 8 yearsI am on Java 7 and maven 3.3, I still have the same issue
-
David Espart almost 8 yearsThis worked for me. More instructions can be found here: maven.apache.org/guides/mini/guide-repository-ssl.html Additionaly, if the certificate from your company is not signed (it's insecure), you need to add the following options anyway
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
-
Harun about 7 yearsI add <plugin>..<arguments>... into pom.xml instead of settings.xml. Adding to settings.xml does not work for me.
-
Giorgi Tsiklauri over 4 yearsAnd how shall we install that SSL certificate?