无法为 https 指定密钥库文件
Can't specify a keystore file for https
我已经(又)玩了好几个小时了。我正在使用 v2.4.6 并尝试使用自定义密钥库文件进行 HTTPS 访问。
Si 我关注了 documentation :
- 在我的 build.sbt 文件中添加了
javaOptions in run += "-Dhttp.port=9020"
- 添加了
play.server.https.keyStore.path = "conf/mykeystorefile.jks
和 play.server.https.keyStore.password = "my_keystore_file_passphrase
然后我像往常一样使用激活器 UI 启动游戏,并且 HTTPS 请求有效,但游戏总是生成一个 generated.keystore
并使用它而不是使用我需要的那个。并打印警告:"Using generated key with self signed certificate for HTTPS. This should not be used in production."
如果我查看 Play 源代码,this 是日志的来源。但是在阅读代码时,只有在未提供 play.server.https.keyStore.path
的情况下才会发生这种情况,它是...
这是怎么回事?
根据你的问题,我猜你是在开发模式下使用 Play。如果是这样,我认为在开发模式下 Play 无法在启动应用程序之前读取这些值(同样的问题使您使用 javaOptions 指定端口)。
您可以尝试使用系统属性 (-Dplay.server.https.(...)
) 指定这些值或在 build.sbt
:
中指定这些选项
devSettings := Map(
"play.server.http.port" -> "9020",
"play.server.https.keyStore.path" -> "/path/to/file",
// (...)
)
注意:不知道这是否是您配置中的拼写错误,但我认为您还需要指定 https.port
...
对于那些真正只想在开发模式下使用它的人...
"You can configure extra settings for the run command in your build.sbt. These settings won’t be used when you deploy your application."
~https://www.playframework.com/documentation/2.5.x/ConfigFile#Extra-devSettings
例如:
PlayKeys.devSettings := Seq(
"https.port" -> "9443",
"play.server.https.keyStore.path" -> "conf/keystore.jks"
)
我已经(又)玩了好几个小时了。我正在使用 v2.4.6 并尝试使用自定义密钥库文件进行 HTTPS 访问。
Si 我关注了 documentation :
- 在我的 build.sbt 文件中添加了
javaOptions in run += "-Dhttp.port=9020"
- 添加了
play.server.https.keyStore.path = "conf/mykeystorefile.jks
和play.server.https.keyStore.password = "my_keystore_file_passphrase
然后我像往常一样使用激活器 UI 启动游戏,并且 HTTPS 请求有效,但游戏总是生成一个 generated.keystore
并使用它而不是使用我需要的那个。并打印警告:"Using generated key with self signed certificate for HTTPS. This should not be used in production."
如果我查看 Play 源代码,this 是日志的来源。但是在阅读代码时,只有在未提供 play.server.https.keyStore.path
的情况下才会发生这种情况,它是...
这是怎么回事?
根据你的问题,我猜你是在开发模式下使用 Play。如果是这样,我认为在开发模式下 Play 无法在启动应用程序之前读取这些值(同样的问题使您使用 javaOptions 指定端口)。
您可以尝试使用系统属性 (-Dplay.server.https.(...)
) 指定这些值或在 build.sbt
:
devSettings := Map(
"play.server.http.port" -> "9020",
"play.server.https.keyStore.path" -> "/path/to/file",
// (...)
)
注意:不知道这是否是您配置中的拼写错误,但我认为您还需要指定 https.port
...
对于那些真正只想在开发模式下使用它的人...
"You can configure extra settings for the run command in your build.sbt. These settings won’t be used when you deploy your application."
~https://www.playframework.com/documentation/2.5.x/ConfigFile#Extra-devSettings
例如:
PlayKeys.devSettings := Seq(
"https.port" -> "9443",
"play.server.https.keyStore.path" -> "conf/keystore.jks"
)