Is production: true
#migrated #maven

Title: Add Security to Maven

Created: 29 Aug 2019 Modified: 29 Aug 2019

Description: A article descritpion how to use the maven master encryption password to encrypt password or secret data that filled in the pom.xml.



I have some maven project that needs authentication to do deployment process, but it’s not safe if i store the raw password in settings.xml.

After some searching on web, below are my tips on process to secure the password.

https://blog.sonatype.com/2009/02/new-feature-maven-settings-password-encryption/

  1. Generate master password

    mvn -emp {master-password} 
    $output: {encrypted master password}
    
  2. Store the master password in settings-security.xml

    <settingsSecurity>
      <master>{encrypted master password}</master>
    </settingsSecurity>
    
  3. Generate password

    mvn -ep {plain text password}
    $output: {encrypted password}
    
  4. Paste the password on settings.xml

    <settings>
      <servers>
        <server>
          <id>nexus</id>
          <username>deployment</username>
    <password>{encrypted password}</password>
        </server>
      </servers>
      ...
    </settings>
    

Further process can be done to provide higher security by relocating the settings-security.xml

  1. Move the settings-security.xml to USB drive

  2. recreate settings-security.xml and append settingsSecurity tag

    <settingsSecurity>
      <relocation>{path to the new settings-security}</relocation>
    </settingsSecurity>
    

[Legacy Link]