Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play 2.1 SSL Configuration

I'm new to Play and in the process of configuring SSL for production. I can successfully run in dev mode with a self signed certificate, but when I try to use a signed certificate the initial client handshake fails and Play generates the following stack trace:

play - Error loading HTTPS keystore from conf/keystore.jks
java.security.NoSuchAlgorithmException: RSA KeyManagerFactory not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) ~[na:1.7.0_11]
at javax.net.ssl.KeyManagerFactory.getInstance(KeyManagerFactory.java:139) ~[na:1.7.0_11]
at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$1.apply(NettyServer.scala:74) [play_2.10.jar:2.1.1]
at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$1.apply(NettyServer.scala:62) [play_2.10.jar:2.1.1]
at scala.Option.map(Option.scala:145) [scala-library.jar:na]
at play.core.server.NettyServer$PlayPipelineFactory.sslContext$lzycompute(NettyServer.scala:62) [play_2.10.jar:2.1.1]

I'm running Play 2.1.1 and Java 1.7.0_11. I've configured ssl support as follows:

//generate a csr

keytool -certreq -alias server -keyalg RSA -file server.csr -keystore keystore.jks

//load root and intermediate certs

keytool -import -alias godaddy -keystore keystore.jks -file gd_bundle.crt

//load signed cert

keytool -import -alias server -keystore keystore.jks -file server.crt

//launch play with system parameters to run ssl

sudo ../../jars/play-2.1.1/play -Dhttps.port=443 -Dhttps.keyStore="conf/keystore.jks" -Dhttps.keyStorePassword=REDACTED -Dhttps.keyStoreAlgorithm="RSA" run

Does anyone know how java.security.NoSuchAlgorithmException: RSA KeyManagerFactory not available error?

like image 458
merritts Avatar asked Jun 11 '13 02:06

merritts


2 Answers

Remove the -Dhttps.keyStoreAlgorithm=RSA from your command. @gma is right, this is the algorithm for the key store, not the key.

I used the following commands to start my play application with a key I generated:

keytool -genkey -alias MyKey -keyalg RSA -keysize 2048 -keystore keystore.jks
play -Dhttps.port=9443 -Dhttps.keyStore=keystore.jks -Dhttps.keyStorePassword=password run

Then pointed my browser to https://localhost:9443

like image 78
Jason Avatar answered Sep 28 '22 03:09

Jason


It is because RSA is not your keyStoreAlgorithm but you Key algorithm. Change -Dhttps.keyStoreAlgorithm="RSA to -Dhttps.keyStoreAlgorithm="jks" as jks is the default format for Java keystores.

like image 41
gma Avatar answered Sep 28 '22 03:09

gma