Maven Nexus Setup tutorial

Technorati 标签: maven, nexus

1. download the Nexus from website for free version:

2. Run the Command prompt with administrator privilege .

http://blog.csdn.net/zwc0910/article/details/17349111

http://w26.iteye.com/blog/1547096

failure reason

http://blog.csdn.net/kimylrong/article/details/23280155

 

3. central repository proxy error:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 http://books.sonatype.com/nexus-book/reference//ssl-sect-client-cert.html

 

tool: http://download.sonatype.com/nexus/import-ssl.jar

4.2.3. Manually Configuring Trust Stores

The Nexus user interface should be sufficient to work with the trust stores and certificates. In older versions of Nexus as well as some use cases, you need to manually configure the trust store.

Sonatype provides an import-ssl tool that can be downloaded fromhttp://download.sonatype.com/nexus/import-ssl.jar. It allows you to import a client certificate in two steps:

  • importing the server’s SSL chain and
  • importing the client SSL key/certificate pair.

The Java Virtual Machine running Nexus uses the Java Secure Socket Extension (JSSE) to enable secure Internet communication. It uses two certificate stores - truststore andkeystore.

A truststore contains certificates from servers run by other parties with who you expect to communicate, or from Certificate Authorities that you trust to identify other parties. This truststore ships with a number of CA’s out-of-the-box, trusted root certificates.

A keystore contains private keys and the certificates with their corresponding public keys. Typically, they are stored in separate files stored in the default location of${JRE_HOME}/lib/security/cacerts.

Some notes about the location of the keystore and default keystore passwords:

  • If you are using the default JSSE keystore locations on either a Linux or OS X platform, you must run the commands below as the root user. You can do this either by changing to the root user (su -) or by using the sudo command: sudo [command].
  • The default password used by Java for the built-in keystores is changeit. If your key-store uses a different password, you’ll need to specify that password as the last parameter on the command lines above.
  • If you want to specify your own keystore/truststore file, provide that in place of in the examples below.
  • If you’re using a password other than changeit for your keystore, you should supply it immediately following the keystore path in the commands below.
  • If you specify a keystore location that doesn’t exist, the import-ssl utility will create it on-demand.

Before you begin the process of importing a Server SSL Chain and a client certificate you will need the following:

  • Network access to the SSL server you are connecting to,
  • An SSL client certificate,
  • and a certificate password.

For server certificates you should either import directly into${JRE_HOME}/lib/security/cacerts, or make a copy of the file and import into that.

If you replace the existing truststore rather than adding to it or if you override the truststore location, you will lose all of the trusted CA root certificates of the JRE and no SSL sites will be accessible.

Import the Server SSL Chain

The first command imports the entire self-signed SSL certificate chain for central.sonatype.com into your JSSE keystore:

$ java -jar import-ssl.jar server repo1.maven.org 
=C:\Java\jdk1.8.0_05\jre\lib\security\cacerts
 
command as below:
java -jar import-ssl.jar server repo1.maven.org C:\Java\jdk1.8.0_05\jre\lib\security\cacerts

Substitute the server name used in the previous listing with the server name to which you are attempting to connect. This particular command will connect to https://repo1.maven.org, retrieve, and import the server’s SSL certificate chain.

Import the Client SSL Key/Certificate Pair

The second command imports your client-side SSL certificate into the JSSE keystore, so Nexus can send it along to the server for authentication:

$ java -jar import-ssl.jar client  \
 keystore

When the client command completes, you should see a line containing the keystore path. Please note this, as you will use it in your next configuration step.

...
Writing keystore: /System/Library/Frameworks/JavaVM.framework/\
Versions/1.6.0/Home/lib/security/jssecacerts

If you want to make a new keystore into which to import your keys, use the keytool that ships with your Java installation to create an empty keystore:

keytool -genkey -alias foo -keystore keystore
keytool -delete -alias foo -keystore keystore

Make sure to use the keytool commands for your Java version used to run Nexus. The documentation for keytool is available online forJava 6 as well as Java 7.

Configuring Nexus Startup

Once both sets of SSL certificates are imported to your keystore and/or truststore, you can modify the wrapper.conf file located in $NEXUS_HOME/bin/jsw/conf/ to inject the JSSE system properties necessary to use these certificates, as seen below adapting the iterator number (10, 11.. ) to start at the last used value, which depends on the rest of your configuration.

wrapper.java.additional.10=-Djavax.net.ssl.keyStore=
wrapper.java.additional.11=-Djavax.net.ssl.keyStorePassword=
wrapper.java.additional.12=-Djavax.net.ssl.trustStore=
wrapper.java.additional.13=-Djavax.net.ssl.trustStorePassword=

Once you have configured the Nexus startup option shown above, restart Nexus and attempt to proxy a remote repository which requires an SSL client certificate. Nexus will use the keystore location and keystore password to configure the SSL interaction to accept the server’s SSL certificate and send the appropriate client SSL certificate using the manual configuration you have completed with the import-ssl tool.

 

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">
  
 <localRepository>C:\Users\alter\.m2\repositorylocalRepository>
 
  <pluginGroups>
      <pluginGroup>org.mortbay.jettypluginGroup>
      <pluginGroup>org.codehaus.cargopluginGroup>
  pluginGroups>

  <proxies>
  proxies>

  <servers>
      <server>
          <id>releasesid>
          <username>deploymentusername>
          <password>deployment123password>
      server>
      <server>
          <id>snapshotsid>
          <username>deploymentusername>
          <password>deployment123password>
      server>  
  servers>

  <mirrors>
    <mirror>
      <id>nexusid>
      <mirrorOf>*mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public/url>
    mirror>
  mirrors>

  <profiles>
    <profile>
      <id>nexusid>
      <repositories>
        <repository>
          <id>centralid>
          <url>http://localhost:8081/nexus/content/groups/public/url>
          <releases><enabled>trueenabled>releases>
          <snapshots><enabled>trueenabled>snapshots>
        repository>
      repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>centralid>
          <url>http://localhost:8081/nexus/content/groups/public/url>
          <releases><enabled>trueenabled>releases>
          <snapshots><enabled>trueenabled>snapshots>
        pluginRepository>
      pluginRepositories>
    profile>
  profiles>

  <activeProfiles>
    <activeProfile>nexusactiveProfile>
  activeProfiles>
settings>

settings>


你可能感兴趣的:(java)