If you have access to openssl, I recommend using this instead of keytool. If you create a certificate signing request, use the -sha256 option to set the hash algorithm you are looking for.
First create a certificate signing request:
$ openssl genrsa -des3 -out server.key 4096 $ openssl req -new -key server.key -out server.csr -sha256
You have a certificate signing request that you optionally signed with a CA. If you want to use a self-signed certificate, you can use the following, otherwise skip this step:
$ openssl genrsa -des3 -out ca.key 4096 $ openssl req -new -x509 -days 365 -key ca.key -out ca.pem $ openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca.key -set_serial 01 -out server.pem
Finally, convert the certificates signed by the server.pem certificate to p7b, as tomcat expects, and then import p7b into the tomcat repository.
$ openssl crl2pkcs7 -nocrl -certfile server.pem -out tomcat2k.p7b -certfile ca.pem $ keytool -import -trustcacerts -alias server -file tomcat2k.p7b -keystore tomcat2k.jks
source share