Play 2.1 SSL Configuration

a 夏天 提交于 2019-12-18 13:23:03

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/17035690/play-2-1-ssl-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!