Play框架2.2.1 HTTPs在连接尝试时失败

我试图在开发模式下在HTTPs上运行play framework 2.2.1应用程序。 我使用以下命令:

Development/Play/ssltest$ JAVA_OPTS=-Dhttps.port=9443 play run 

我得到了以下,这似乎没问题

 --- (Running the application from SBT, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 [info] play - Listening for HTTPS on port /0:0:0:0:0:0:0:0:9443 (Server started, use Ctrl+D to stop and go back to the console...) 

但是,当我尝试通过HTTPS连接到应用程序时:

 "https://localhost:9443" 

应用程序崩溃,我进入以下一堆例外:

 [error] play - Error loading fake key store java.security.cert.CertificateException: Subject class type invalid. at sun.security.x509.X509CertInfo.setSubject(X509CertInfo.java:888) ~[na:1.8.0-ea] at sun.security.x509.X509CertInfo.set(X509CertInfo.java:415) ~[na:1.8.0-ea] at play.core.server.netty.FakeKeyStore$.createSelfSignedCertificate(FakeKeyStore.scala:71) ~[play_2.10.jar:2.2.1] at play.core.server.netty.FakeKeyStore$.keyManagerFactory(FakeKeyStore.scala:34) ~[play_2.10.jar:2.2.1] at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:98) [play_2.10.jar:2.2.1] at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:94) [play_2.10.jar:2.2.1] [info] play - Application started (Dev) [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: invalid version format: ホᆱ?BYFᅤロ￵ ̄X￶￧ᆪヌ$￀+￀/゙ワ￀at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:102) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: invalid version format: ホᆱ?BYFᅤロ￵ ̄X￶￧ᆪヌ$￀+￀/゙ワ￀at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:102) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: invalid version format: ￀at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:102) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: invalid version format: ￀at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:102) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] [error] p.nettyException - Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:97) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na] 

这里讨论的问题是: https : //groups.google.com/forum/#!msg / play-framework / ip6cT70VjZ4 / I5cHNv0rOWkJ

问题是将https请求发送到localhost。 解决方案是:

  1. 简单的方法:保留localhosturl,但用http取代https
  2. 困难的方法:通过搞乱/ etc / hosts设置正确的域名映射,并配置ssl在localhost上运行

我的机器上的播放似乎无法生成自签名证书。 如果我使用自己的自签名证书,它没有问题。

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

我从[post]( Play 2.1 SSL配置 )得到了答案

您是否尝试过https://localhost:9443 (注意9443之前的冒号而不是斜线)

您提供的证书/密钥库的路径可能无效。

我也有同样的问题。

如果您使用的是ssl ,请尝试删除conf/generated.keystore ,重新启动服务器(使用-Dhttps.port=9443选项)。 将自动创建新证书并解决问题