使用HTTPS / SSL启动Typesafe Play Framework

时间:2015-09-07 16:54:15

标签: ssl https playframework configuration keystore

我无法使用HTTPS启动和运行系统。

我已经从通配符证书创建了一个密钥文件,并将密钥文件放在我们的./conf目录中:

473 zbeckman:glimpulse-server$ ll conf
total 72
drwxr-xr-x 9 zbeckman staff 306 Sep 7 09:26 ./
drwxr-xr-x 22 zbeckman staff 748 Sep 7 09:32 ../
-rwxr-xr-x 1 zbeckman staff 1213 Sep 7 09:26 application.conf*
-rw-r--r-- 1 zbeckman staff 1374 Sep 7 08:49 glimpulse.keystore
-rw-r--r-- 1 zbeckman staff 1439 Aug 9 15:58 logback.xml
-rwxr-xr-x 1 zbeckman staff 5206 Aug 8 15:36 routes*
-rw-r--r-- 1 zbeckman staff 575 Apr 29 18:55 ws.conf
474 zbeckman:glimpulse-server$

我已根据Play Configuring HTTPS页面中的说明将以下内容添加到./conf/application.conf文件中:

play.server.https.keyStore.path = "./conf/glimpulse.keystore"
play.server.https.keyStore.password = "xxxxxxxxxxxxx"

最后,我正在使用-Dhttp.port=disabled -Dhttps.port=9000尝试启动服务器,但它拒绝启动。

以下是结果。注意输出的最后一行:

472 zbeckman:glimpulse-server$ ./activator start -Dhttp.port=disabled -Dhttps.port=9000
[info] Loading project definition from /Users/zbeckman/Projects/Glimpulse/Server/project/glimpulse-server/project
[info] Set current project to Glimpulse (in build file:/Users/zbeckman/Projects/Glimpulse/Server/project/glimpulse-server/)
[warn] The start command is deprecated, and will be removed in a future version of Play.
[warn] To run Play in production mode, run 'stage' instead, and then execute the generated start script in target/universal/stage/bin.
[warn] To test your application using production mode, run 'testProd' instead.
[info] Wrote /Users/zbeckman/Projects/Glimpulse/Server/project/glimpulse-server/target/scala-2.11/glimpulse_2.11-1.0-SNAPSHOT.pom

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Must provide either an HTTP or HTTPS port
473 zbeckman:glimpulse-server$

就密钥库而言,我使用Java keytool根据我们的通配符域证书生成商店:

keytool -import -alias tomcat -keystore glimpulse.keystore -trustcacerts -file star_glimpulse_com.crt

这似乎很好,并且生成的密钥库没有任何错误或警告。

2 个答案:

答案 0 :(得分:1)

您可以尝试像这样运行它:

./activator "start -Dhttp.port=disabled -Dhttps.port=9000"

可能需要引号以确保参数以正确的方式传递给start命令。

答案 1 :(得分:0)

只需将其添加到您的application.conf:

https {
  # The HTTPS port of the server.
  port = 9001
}

并且您的应用将侦听端口9001