Encrypt tomcat keystore password

前端 未结 6 962
北海茫月
北海茫月 2020-12-25 08:44

Is there an option to encrypt keystorePass value in tomcat server.xml? I don\'t want it to be a plain text

    

        
6条回答
  •  感情败类
    2020-12-25 09:03

    There is a better way, than just using the XML encode.

    Create an Encryption Class to encrypt and decrypt your password.

    And override Http11Nio2Protocol class, something similar to the below code.

     public class Http11Nio2Protocol extends org.apache.coyote.http11.Http11Nio2Protocol {
    
    @Override
    public void setKeystorePass(String s) {
        try {
            super.setKeystorePass(new EncryptService().decrypt(s));
        } catch (final Exception e){
            super.setKeystorePass("");
        }
    }
    

    }

    Note: EncryptService is our own encryption class.

    And configure the overridden class in the protocol attribute in server.xml like below.

    
    

    Hope this helps.

提交回复
热议问题