MyCATApache/Mycat-Server · error · ConfigException

user passwrod need to decrype ,but decrype password is…

Error message

user {user} passwrod need to decrype ,but decrype password is wrong !

What it means

DecryptUtil.mycatDecrypt decrypts an encrypted Mycat user credential of the form 'encrypted:user:password'. After decryption it verifies the version flag ('0') and that the decrypted user matches the expected user; if verification fails or decryption throws, it wraps the problem in a ConfigException saying the encrypted password is wrong.

Solutions

  1. Re-encrypt the credential with the correct tool (Mycat encode for version 0) and update server.xml.
  2. Ensure the encrypted payload's embedded username matches the configured user exactly.
  3. Verify the format: decrypt(password) must yield '0:user:password'.
  4. Set usingDecrypt to false/remove it if you intend to use plaintext passwords.

Example fix

// before
<user name="app" usingDecrypt="1" password="WRONGENCRYPTED"/>
// after
<user name="app" usingDecrypt="1" password="<correctly encoded 0:app:secret>"/>
Defensive patterns

Strategy: validation

Validate before calling

// verify encrypted credential before applying config
String decoded = new String(java.util.Base64.getDecoder().decode(encPassword));
String[] parts = decoded.split(":");
if (!("0".equals(parts[0]) && user.equals(parts[1]) && parts.length == 3))
    throw new IllegalStateException("encrypted password does not match user " + user);

Try / catch

try { loadMycatConfig(); } catch (ConfigException e) { if (e.getMessage().contains("decrype")) { reencryptCredentials(cfg); loadMycatConfig(); } else throw e; }

Prevention

When it happens

Trigger: server.xml/user config with usingDecrypt enabled and a password that does not decrypt to '0:<user>:<password>' matching the configured user name; corrupt or wrongly generated encrypted string; user renamed without re-encrypting.

Common situations: Regenerating passwords with a different Mycat encode tool version; copying an encrypted password between users; typos in the encrypted string; enabling usingDecrypt but leaving plaintext passwords.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/721f63a0bff4c8a7. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/util/DecryptUtil.java:89

        + "\t\t<property name=\"schemas\">TESTDB</property>");
		String password = args[0];
		System.out.println(encrypt(password));
	}
	
	public static String mycatDecrypt(String usingDecrypt,String user ,String passwrod){
		if("1".equals(usingDecrypt)||"true".equalsIgnoreCase(usingDecrypt)){
        	//type:user:password
        	//0:test:test
        	boolean flag = false;
        	try {
        		String passwrods[] = DecryptUtil.decrypt(passwrod).split(":");
            	if("0".equals(passwrods[0])
						&& user.equals(passwrods[1])){
                        flag = true;
            			return passwrods[2];
            	}
            	if(flag==false){
            		 throw new ConfigException("user " + user + " passwrod need to decrype ,but decrype password is wrong !");
            	}
        	} catch (Exception e2) {
       		    throw new ConfigException("user " + user + " passwrod need to decrype ,but decrype password is wrong !",e2);
			}
		}
		return passwrod;
	}
	public static String DBHostDecrypt(String usingDecrypt,String host,String user ,String passwrod){
		if("1".equals(usingDecrypt)||"true".equalsIgnoreCase(usingDecrypt)){
			//type:host:user:password
        	//1:myhost1:test:test
        	boolean flag = false;
        	try {
        		String passwrods[] = DecryptUtil.decrypt(passwrod).split(":");
            	if("1".equals(passwrods[0]) && host.equals(passwrods[1]) && user.equals(passwrods[2])){
            		return passwrods[3];
            	}
            	if(flag==false){

View on GitHub (pinned to 65f8d8beb7)