Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337175

Summary: Empty files downloaded with repository manager requires authentication
Product: z_Archived Reporter: Brock Janiczak <brockj>
Component: m2eAssignee: Project Inbox <m2e.core-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: igor, jfarcand, pascal
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
log from workspace none

Description Brock Janiczak CLA 2011-02-14 19:35:01 EST
Version 0.13.0.201102141205

We have a nexus repository that requires authentication that is accessible only via SSL and all artifacts downloaded are empty.

Turning on javax.net debugging shows that the initial request to the server does not include credentials and the server responds with a 401.  The connection is then dropped.

Is there any way to enable pre-emptive authentication when the async http client is being used?  It looks like you could do this with the old wagon transport.
Comment 1 Pascal Rapicault CLA 2011-02-14 21:18:54 EST
Could you please tell me if the same issue occurs with the M5 build (http://download.eclipse.org/technology/m2e/updates/M)

Thx
Comment 2 Igor Fedorenko CLA 2011-02-14 21:43:07 EST
I am not able to reproduce the problem locally. In addition to the test requested by Pascal, can you provide the following 

* *obfuscated* settings.xml where we can see how <server> and <mirror> and/or <repository> elements are related, but not actual hostnames and passwords (obviously)

* Relevant parts of AHC debug log. In my environment I have logback configured to print to STDOUT, which is default eclipse logback configuration, but you may need to do something special (we are currently working on logging infrastructure, so I am not sure what your exact build has).



As a point of reference, here is my (obfuscated) test settings.xml I used to verify ssl with username/password authentication



<settings>
  <servers>
   <server>
     <id>nexus</id>
     <username>XXX</username>
     <password>YYY</password>
   </server>
  </servers>
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>external:*</mirrorOf>
      <url>https://repository.sonatype.org/content/groups/A-PRIVATE-GROUP</url>
    </mirror>
  </mirrors>
</settings>





Here is corresponding AHC debug log that shows auth challenge and subsequent basic auth request


Request DefaultHttpRequest(chunked: false)
GET /content/groups/A-PRIVATE-GROUP/org/apache/maven/archetypes/maven-archetype-quickstart/maven-metadata.xml HTTP/1.1
Host: repository.sonatype.org
Pragma: no-cache
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Accept-Encoding: gzip
Connection: keep-alive
User-Agent: Aether

Response DefaultHttpResponse(chunked: true)
HTTP/1.1 401 Unauthorized
Server: nginx/0.8.40
Date: Tue, 15 Feb 2011 02:22:37 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: JSESSIONID=612d0c2d-f125-442f-870d-ec111f3d95f7; Path=/; HttpOnly
Set-Cookie: rememberMe=deleteMe; Path=/; Expires=Mon, 14-Feb-2011 02:22:37 GMT
Set-Cookie: rememberMe=deleteMe; Path=/; Expires=Mon, 14-Feb-2011 02:22:37 GMT
Set-Cookie: JSESSIONID=deleteMe; Path=/; Expires=Mon, 14-Feb-2011 02:22:37 GMT
WWW-Authenticate: BASIC realm="Sonatype Nexus Repository Manager"

21:22:30.203 [New I/O client worker #4-1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - Sending authentication to https://repository.sonatype.org/content/groups/A-PRIVATE-GROUP/org/apache/maven/archetypes/maven-archetype-quickstart/maven-metadata.xml
21:22:30.204 [New I/O client worker #4-1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - 

Cached Request [id: 0x7ec2adcb, /192.168.2.101:33667 => repository.sonatype.org/63.246.20.88:443]

21:22:35.477 [New I/O client worker #4-1] DEBUG c.n.h.c.p.n.NettyAsyncHttpProvider - 

Request DefaultHttpRequest(chunked: false)
GET /content/groups/A-PRIVATE-GROUP/org/apache/maven/archetypes/maven-archetype-quickstart/maven-metadata.xml HTTP/1.1
Host: repository.sonatype.org
Pragma: no-cache
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Accept-Encoding: gzip
Authorization: Basic XXXXXXXXXXXXX
Connection: keep-alive
User-Agent: Aether

Response DefaultHttpResponse(chunked: false)
HTTP/1.1 200 OK
Server: nginx/0.8.40
Date: Tue, 15 Feb 2011 02:22:43 GMT
Content-Type: application/xml
Connection: keep-alive
Set-Cookie: JSESSIONID=9fb95d0e-c180-47ba-a8ee-4ac51ddbf6a7; Path=/; HttpOnly
Set-Cookie: rememberMe=deleteMe; Path=/; Expires=Mon, 14-Feb-2011 02:22:37 GMT
Last-Modified: Mon, 01 Nov 2010 00:08:09 GMT
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Content-Length: 606
Comment 3 Brock Janiczak CLA 2011-02-14 23:42:22 EST
Created attachment 188973 [details]
log from workspace

Attached is a sample from my workspace log.  It does seem to show the authentication challenge working, but failing to log in.  I am pretty sure i have the correct credentials though as it works from the commandline
Comment 4 Brock Janiczak CLA 2011-02-14 23:45:20 EST
My settings aren't that interesting:
<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
	  <url>https://nexus.gbst.com/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>
    <servers>
    <server>
      <id>nexus</id>
      <username>gbst</username>
      <password>password</password>
    </server>
  </servers>
  
    <proxies>
    <proxy>
      <id>webproxy</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>web-proxy.gbst.net</host>
      <port>8080</port>
    </proxy>
  </proxies>
</settings>

basically, we h ave a local mirror of everything that we access via a proxy over HTTPS.
Comment 5 Igor Fedorenko CLA 2011-02-15 10:07:57 EST
I introduced squid http proxy, I can confirm traffic flows through the proxy but still can't reproduce the problem. What is your http(s) proxy server software? Is there anything special about http proxy server configuration?
Comment 6 Brock Janiczak CLA 2011-02-15 17:20:15 EST
I think we are using sophos web appliance or something like that.  Although we go though a proxy, the repository is on our internal network.

Can you provide instructions on how to setup better logging?  I don't seem to be getting that much when running the embedded maven launches.  -X and -Djavax.net.debug=all is the best i can do.  I am not getting any logging from maven internals.
Comment 7 jfarcand CLA 2011-02-16 14:46:30 EST
(In reply to comment #6)
> I think we are using sophos web appliance or something like that.  Although we
> go though a proxy, the repository is on our internal network.
> 
> Can you provide instructions on how to setup better logging?  I don't seem to
> be getting that much when running the embedded maven launches.  -X and
> -Djavax.net.debug=all is the best i can do.  I am not getting any logging from
> maven internals.

Do you think you can get a dump of the bytes between the client and the proxy. For a reason I can't explain the proxy seems to close the connection before AHC have chance to push the bytes.

If you can't, drop me an email at jfarcand [at] apache [dot] org and I will send you an ahc version with more debug statement.

Thanks!!
Comment 8 Pascal Rapicault CLA 2011-02-23 10:55:49 EST
Where are we at on this?
Comment 9 Brock Janiczak CLA 2011-02-23 17:17:32 EST
(In reply to comment #8)
> Where are we at on this?

Hi Pascal,
I sent Jean-francois the information offline as it contained some sensitive information.  He provided debug builds of async http client and the aether connector.  I tried replacing thejars in my installation, but it didn't seem to help.

It would be great if someone could provide more details on how to enable detailed logging for the embedded maven launcher.  I have just updated to M2e version 0.13.0.201102231405 (from the nightly update site)
Comment 10 Pascal Rapicault CLA 2011-02-24 20:26:02 EST
To enable more logging, go in your workspace, navigate to .metadata/.plugins/org.eclipse.m2e.logback.configuration/, edit the most recent logback.<someNumber>.xml to change   <logger name="com.ning.http.client" level="INFO" /> to   <logger name="com.ning.http.client" level="DEBUG" />

I think this should do the trick to generate more data about the transport.
Comment 11 Brock Janiczak CLA 2011-02-24 23:27:14 EST
Thanks Pascal, it worked, but i think there is another issue.  My embedded maven is displaying an error which indicates it isn't using the logger :(

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Comment 12 Pascal Rapicault CLA 2011-02-25 13:09:21 EST
Make sure that you have the m2e logging support installed: 
  Maven Integration for Eclipse - slf4j over logback logging (Optional)	0.13.0.201102250406	org.eclipse.m2e.logback.feature.feature.group

You can get it from our Nightly repo.
Comment 13 Igor Fedorenko CLA 2012-05-21 11:25:11 EDT
Closing old/stale bugreports.
Comment 14 Denis Roy CLA 2021-04-19 13:26:34 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/