Executing commands with required subcommands in task

currently my task executes the command to generate a ca.key, but usually the command requires the user to input a desired password. How can I get gradle to automatically fill in a passphrase/other types of input upon running the task?

doLast {
exec {
workingDir ‘./cert-test’
executable ‘sh’
args ‘-e’, ‘-c’, ‘openssl genrsa -des3 -out ca.key 4096’
}
}