Jasypt: read configuration from external file

929 views Asked by At

I am using grails Jasypt Encryption plugin to encrypt my data in the DB.

If I set jasypt configurations in my Config.groovy file like:

jasypt {
    algorithm = "PBEWITHSHA256AND256BITAES-CBC-BC"
    providerName = "BC"
    password = "myPassphrase"
    keyObtentionIterations = 1000
}

then everything is working fine.

But if I move the jasypt configurations in an external file as mentioned in the jasypt doc(External Config Files in Grails) then these configuration are not being accessed.

How to access jsypt external configuration file?

Note:- Using ubuntu

2

There are 2 answers

1
Andrew On BEST ANSWER

Since your Jasypt config block uses ConfigSlurper syntax, your external config file needs a .groovy extension (e.g. .jasypt.groovy) Or, you could switch to Java .properties syntax.

1
piet.t On

If you just copy-pasted this section:

def configFIlePath = System.getenv('ENCRYPTION_CONFIG_LOCATION') ?: "file:${userHome}/.jasypt"
grails.config.locations = [configFilePath]

pay special attention to the typo: in the first line it must be configFilePath with a lower-case i!!