码迷,mamicode.com
首页 > 其他好文 > 详细

play framework SSL

时间:2015-04-03 13:32:34      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:play framework   ssl   


play framework SSL

openssl -genrsa -des3 -out host.key 2048

参数解释:
    genrsa
        用于生成RSA密钥对的OpenSSL命令
    -des3
        使用3-DES对称加密算法加密密钥对,该参数需要用户在密钥生成过程中输入一个口令用于加密。今后使用该密钥对时,需要输入相应的口令。如果不加该选项,则不对密钥进行加密。
    -out
        令生成的密钥对保存到文件 host.key
    2048
        RSA模数倍数,在一定程度上表现了密钥密度。


    
openssl req -new -key ssl.key -out ssl.csr

参数解释:
    req
        用于生成证书请求的OpenSSL命令
    -new
        生成一个新的证书请求。该参数将令OpenSSl在证书请求生成中需要用户填写一些相应的字段。
    -key
        指定ssl.key为证书所使用的密钥对文件。
    -out
        令生成的证书请求保存到文件host.csr

    Enter pass phrase for host.key:  //输入密码(如果之前生成host.key时加参数-des3)
    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    What you are about to enter is what is called a Distinguished Name or a DN.
    There are quite a few fields but you can leave some blank
    For some fields there will be a default value,
    If you enter ‘.‘, the field will be left blank.
    -----
    Country Name (2 letter code) [AU]://使用国际标准组织(ISO)国码格式,填写2个字母的国家代号。中国请填写CN。
    State or Province Name (full name) [Some-State]://省份,比如填写BeiJing
    Locality Name (eg, city) []://城市,比如填写BeiJing
    Organization Name (eg, company) [Internet Widgits Pty Ltd]://组织单位,比如填写公司名的拼音
    Organizational Unit Name (eg, section) []://比如填写IT Dept
    Common Name (e.g. server FQDN or YOUR name) []://行使 SSL 加密的网站地址。请注意这里并不是单指您的域名,而是直接使用 SSL 的网站名称 例如:pay.abc.com。 一个网站这里定义是:abc.com 是一个网站; www.abc.com 是另外一个网站; pay.abc.com 又是另外一个网站。 注意:这个服务器域名应该和邮件客户端软件设置的SMTP/POP3服务器名称一致。
    Email Address []:// 邮件地址,可以不填

    Please enter the following ‘extra‘ attributes
    to be sent with your certificate request
    A challenge password []://可以不填
    An optional company name []://可以不填


openssl x509 -req -days 365 -in host.csr -signkey host.key -out host.cert

参数解释:
    x509
        生成一份X.509证书。
    -req
        用户生成证书请求的OpenSSL命令。
    -days 365
        从生成之时算起,证书时效为365天。
    -in
        指定host.csr为证书请求文件
    -signkey
        指定host.key为密钥对文件
    -out
        令生成的证书文件保存到文件host.cert

如何之前设置过密码,会提示你输入密码。如果服务器找host.crt,则可以使用cp host.cert host.crt

最后把host.key host.cert这两个文件放到conf配置文件下,打开application.conf
加入
https.port=9443

certificate.key.file=conf/host.key
certificate.file=conf/host.cert
certificate.password=123456(自己之前设置的密码)
trustmanager.algorithm=JKS

访问:https://localhost:9443/


play framework SSL

标签:play framework   ssl   

原文地址:http://blog.csdn.net/maktub_haixue/article/details/44853405

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!