openssl req -new -newkey rsa:2048 -nodes -keyout 1dottea.com.key -out domain.com.csr


这条命令将会生成2个文件:1个csr文件和1个key文件

domain.com.csr

domain.com.key



将csr文件内容复制粘贴到godaddy中,点击申请。


申请成功之后,下载将会得到一个zip压缩包,我选择的时候选择的是其他类型(没有nginx服务器,所以选择的其他)。


压缩包里面有2个类似下面的文件

313fd7ca5877f128.crt

gd_bundle-g2-g1.crt


执行下面的命令:


cat 313fd7ca5877f128.crt gd_bundle-g2-g1.crt > domain.com.crt


这时候得到的crt文件和key文件就可以拿到nginx下配置使用了。


===================================================================================



但如果想将这时候的crt文件和key文件转换成tomcat下面使用的keystone文件,则需要利用下面的两条命令。

[root@localhost tomcat]# openssl pkcs12 -export -in domain.name.crt -inkey domain.name.key -out mycert.p12 -name tomcat -CAfile domain.name.crt -caname root -chain
Enter Export Password:
Verifying - Enter Export Password:


[root@localhost tomcat]# keytool -importkeystore -v  -srckeystore mycert.p12 -srcstoretype pkcs12 -destkeystore tomcat.keystore -deststoretype jks
Enter destination keystore password:  
Re-enter new password: 
Enter source keystore password:  
Entry for alias tomcat successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled
[Storing tomcat.keystore]


这2条命令要感谢下这篇文章的作者:

http://www.oschina.net/question/2266279_221175?sort=time



在tomcat的配置如下:



    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"

               maxThreads="150" 

               SSLEnabled="true" 

               scheme="https"

               secure="true"

               clientAuth="false" 

               sslProtocol="TLS" 

               keystoreFile="/root/ssl/tomcat/tomcat.keystore"

               keystorePass="123456" 

 

/>


这段代码本来是注释的,取消掉注释,然后修改下就可以了。

然后在浏览器中输入地址:

https://www.domain.name:8443/webapp_name


这样就可以看到期待的绿色了。


之后测试,完全正常。