Chr*_*ris 18 ssl playframework playframework-2.0
我已经阅读了 如何配置playframework服务器以支持ssl ,我也试图关注http://www.playframework.org/documentation/1.1.1/releasenotes-1.1#https但它对我不起作用
非常感谢〜
我阅读了Play1的文档,因为我无法找到有关https的Play2的更新信息.
在application.conf中,我添加了以下行:
https.port=9443
certificate.key.file=conf/host.key
certificate.file=conf/host.cert
Run Code Online (Sandbox Code Playgroud)
我键入run
播放控制台,并尝试在https://localhost:9443
浏览器超时时访问服务器,而无需在控制台输出中记录任何内容
Nas*_*sir 24
它不适用于您正在采取的方法.您错误地将1.x分支的发行说明与2.x分支相关联.
在1.x分支中,它是可能的.发行说明就足够了,它们对我有用.
对于2.1+分支,请参阅@Christina的评论.2.1中添加了支持,讨论线程提供了详细信息.
引用James Roper的回应
在开发模式下,它非常简单,只需:
JAVA_OPTS = -Dhttps.port = 9443播放
Play会生成一个私钥和自签名证书,显然你的浏览器会对一个大的红色警告不屑一顾.它将为每次后续的Play运行重用生成的自签名证书,因此您应该只获得一次浏览器错误.显然,这个自签名证书可能不是你想要的.另外需要注意的是,自签名证书生成仅适用于使用Sun安全库的JVM(例如Oracle和OpenJDK,但最值得注意的不是IBM J9).在不使用这些JVM的JVM上,当它尝试生成证书时,您将获得NoClassDefFoundError.
在prod中(此配置也适用于dev),您的配置方式与通常在Java中通过系统属性配置SSL的方式相同.这是一个总结:
https.port - 应该使用的端口
https.keyStore - 包含私钥和证书的密钥库的路径(如果未提供)会为您生成密钥库
https.keyStoreType - 密钥库类型,默认为"JKS"
https.keyStorePassword - 密码,默认为""
https.keyStoreAlgorithm - 密钥存储算法,默认为平台默认算法
https.trustStore - 此功能尚未完全实现,目前它将始终使用JDK信任存储来验证客户端证书(您当然可以自行配置),无论您是否为此提供值,除非您指定" noCA",在这种情况下,它将使用信任存储,信任所有证书而不进行验证或验证,这对于使用webid客户端证书验证很有用.
对于2.0分支,你必须放置另一个服务器,即apache/nginx/other监听https并转发请求以在http中播放.
有关设置前端服务器的说明,请访问http://www.playframework.org/documentation/2.0.1/HTTPServer
因此,在端口上运行播放服务器.将domain.com的apache转发请求发送到127.0.0.1:9443.
示例apache配置
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias *.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
ProxyPreserveHost On
# ProxyPass /excluded !
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.
归档时间: |
|
查看次数: |
16508 次 |
最近记录: |