2012-05-15 6 views
5

Tôi có một Nexus có sẵn qua HTTPS. Chỉ những người dùng được ủy quyền mới có quyền truy cập vào nó. Sử dụng Maven, khi tất cả các đồ tạo tác được yêu cầu đều có trong repo cục bộ, tôi thậm chí có thể triển khai vật phẩm xây dựng. Nhưng khi tôi loại bỏ một số đồ tạo tác bắt buộc từ kho lưu trữ cục bộ, quá trình tạo không thành công.Maven không thể tải xuống các hiện vật từ HTTPS Nexus với xác thực bắt buộc

Downloading: https://example.com/nexus/content/groups/all/org/springframework/spring-test-mvc/1.0.0.BUILD-SNAPSHOT/spring-test-mvc-1.0.0.BUILD-SNAPSHOT.pom 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] example - project1 ..................................... SUCCESS [0.500s] 
[INFO] example - project2 ..................................... FAILURE [2.951s] 
[INFO] example - project3 ...................................... SKIPPED 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3.599s 
[INFO] Finished at: Tue May 15 13:58:13 EEST 2012 
[INFO] Final Memory: 6M/121M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal on project example - project2: Could not resolve dependencies for project com.example:example-project:jar:1.2.0-SNAPSHOT: Failed to collect dependencies for [com.example:example-project:jar:1.2.0-SNAPSHOT (compile), org.springframework:spring-beans:jar:3.1.1.RELEASE (compile), org.springframework:spring-context:jar:3.1.1.RELEASE (compile), org.springframework:spring-core:jar:3.1.1.RELEASE (compile), org.springframework:spring-test:jar:3.1.1.RELEASE (test), org.springframework:spring-web:jar:3.1.1.RELEASE (compile), org.apache.httpcomponents:httpclient:jar:4.1.1 (test), org.codehaus.jackson:jackson-mapper-asl:jar:1.9.6 (compile), org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT (test), junit:junit:jar:4.10 (test), org.mockito:mockito-all:jar:1.9.0 (test), org.hamcrest:hamcrest-all:jar:1.1 (compile), org.slf4j:slf4j-api:jar:1.6.1 (compile), org.slf4j:slf4j-log4j12:jar:1.6.1 (compile), log4j:log4j:jar:1.2.16 (compile), log4j:apache-log4j-extras:jar:1.1 (compile)]: Failed to read artifact descriptor for org.springframework:spring-test-mvc:jar:1.0.0.BUILD-SNAPSHOT: Could not transfer artifact org.springframework:spring-test-mvc:pom:1.0.0.BUILD-SNAPSHOT from/to nexus (https://example.com/nexus/content/groups/all): Not authorized, ReasonPhrase:Unauthorized. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException 
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command 
[ERROR] mvn <goals> -rf :grc-webclient-services 

Có nội dung sau đây trong settings.xml của người dùng của tôi:

<settings> 
<pluginGroups> 
    </pluginGroups> 
    <proxies> 
    </proxies> 
    <mirrors> 
     <mirror> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>https://example.com/nexus/content/groups/all</url> 
     </mirror> 
    </mirrors> 

    <profiles> 
     <profile> 

      <id>nexus</id> 

      <properties> 
       <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonardb?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url> 
       <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName> 
       <sonar.jdbc.username>sonarusername</sonar.jdbc.username> 
       <sonar.jdbc.password>sonarpw</sonar.jdbc.password> 
       <sonar.host.url>http://localhost:9000/</sonar.host.url> 
      </properties> 


      <repositories> 
       <repository> 
        <id>central</id> 
        <url>https://example.com/nexus/content/groups/all</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </repository> 
      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <id>central</id> 
        <url>https://example.com/nexus/content/groups/all</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </pluginRepository> 
      </pluginRepositories> 

     </profile> 
    </profiles> 

    <servers> 
     <server> 
      <id>all</id> 
      <username>user</username> 
      <password>pw</password> 
     </server> 
     <server> 
      <id>releases</id> 
      <username>user</username> 
      <password>pw</password> 
     </server> 
     <server> 
      <id>snapshots</id> 
      <username>user</username> 
      <password>pw</password> 
     </server> 
    </servers> 

    <activeProfiles> 
     <activeProfile>nexus</activeProfile> 
    </activeProfiles> 

</settings> 

Khi tôi tải về hiện vật từ Nexus này sử dụng wget, tôi đã có thêm --no-check-Giấy chứng nhận chìa khóa để bỏ qua chứng chỉ của máy chủ (vì nó là tự ký) và sau đó tôi có thể tải xuống bằng cách sử dụng wget.

Tôi thích phím Java -Dsun.security.ssl.allowUnsafeRenegotiation = true, nhưng nó không thay đổi gì cả.

Sau đó tôi phát hiện ra rằng nó có lẽ không phải là một vấn đề chứng chỉ tự ký vì tôi đã thêm chứng chỉ máy chủ của vào danh sách đáng tin cậy sử dụng lệnh:

keytool -keystore $JAVA_HOME/jre/lib/security/cacerts -import -file certificate.cer 

Liệu ai đó có một ý tưởng làm thế nào tôi có thể tải về các hiện vật từ Nexus trong thời gian xây dựng?

+0

Phần Nga là một chút khó hiểu :-) Nhưng bạn đã thử [hướng dẫn này] (http: //maven.apache .org/guides/mini/guide-repository-ssl.html)? – Paaske

+0

Tôi không chắc chắn nếu nhận xét trước đó đề cập đến những gì bạn cần. Nếu nó chỉ là vấn đề truy cập vào repo trên một máy chủ có chứng chỉ tự ký, thì việc thêm chứng chỉ vào kho khóa Java là đủ. – Paaske

+0

Tôi đã thêm một tài khoản. Có lẽ không đúng cách. Làm thế nào tôi có thể kiểm tra chứng chỉ đó được thêm vào? Ngoài ra tôi đã phân tích lưu lượng truy cập bằng cách sử dụng WireShark trong khi kết nối với Nexus, tôi thấy gói Encription Alert với SSL Content-type: Alert (21). –

Trả lời

4

tôi đã phải thay đổi

<server> 
     <id>all</id> 
     <username>user</username> 
     <password>pw</password> 
    </server> 

để

<server> 
     <id>nexus</id> 
     <username>user</username> 
     <password>pw</password> 
    </server> 

nơi 'mối quan hệ' là định danh của gương của tôi ở phía trên cùng settings.xml.

-3

Thêm toa xe-http nhẹ mở rộng, Nice Giải thích

Best solution to maven proxy configure

+1

Vui lòng thêm một số nội dung và giải thích cho nội dung câu trả lời thay vì chỉ liên kết đến một trang web khác để người dùng đọc – Crowie