Spark allows you to retrieve the key password and also make it accessible to different components. Refer to the below command to know how to do this:
hadoop credential create spark.ssl.keyPassword -value password \
-provider jceks://hdfs@nn1.example.com:9001/user/backup/ssl.jceks