手机版
你好,游客 登录 注册
背景:
阅读新闻

CentOS 5.5基础教程系列

Tomcat SSL的配置

[日期:2011-04-16] 来源:Linux社区  作者:kj_zx19854 [字体:大 中 小]
目标:建立自己的CA中心,用自己的CA去给Tomcat签发证书,签发客户端。

查看openssl的版本:

  1. # openssl version   
  2. OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008  
  3. //版本有点老。下篇在说升级的事。  
第一步,建立自己的CA中心。
  1. # cd /usr/   
  2. # mkdir ./vanessl/   
  3. # cd ./vanessl/   
  4. # openssl genrsa -out ca-key.pem 1024  
  5. # openssl req -new -out ca-req.csr -key ca-key.pem   
  6. //You are about to be asked to enter information that will be incorporated   
  7. //into your certificate request.   
  8. //What you are about to enter is what is called a Distinguished Name or a DN.   
  9. //There are quite a few fields but you can leave some blank   
  10. //For some fields there will be a default value,   
  11. //If you enter '.', the field will be left blank.   
  12. //-----   
  13. //Country Name (2 letter code) [GB]:CN   
  14. //State or Province Name (full name) [Berkshire]:Yun Nan   
  15. //Locality Name (eg, city) [Newbury]:Kun Ming   
  16. //Organization Name (eg, company) [My Company Ltd]:Delochi   
  17. //Organizational Unit Name (eg, section) []:Software   
  18. //Common Name (eg, your name or your server's hostname) []:Delochi CA Root   
  19. //Email Address []:   
  20. //Please enter the following 'extra' attributes   
  21. //to be sent with your certificate request   
  22. //A challenge password []:   
  23. //An optional company name []:   
  24. # openssl x509 -req -in ca-req.csr -out ca-cert.pem -signkey ca-key.pem -days 365  
  25. //Signature ok   
  26. //subject=/C=CN/ST=Yun Nan/L=Kun Ming/O=Delochi/OU=Software/CN=Delochi CA Root   
  27. //Getting Private key   
  28. # echo 01>ca-cert.srl   
  29. # cp ca-cert.pem ca-cert.cer   
  30. # keytool -import -v -trustcacerts -alias delochi_ca_root -file ca-cert.pem -keystore $Java_HOME/jre/lib/security/cacerts   
  31. //Enter keystore password:  changeit   
  32. //Owner: CN=Delochi CA Root, OU=Software, O=Delochi, L=Kun Ming, ST=Yun Nan, C=CN   
  33. //Issuer: CN=Delochi CA Root, OU=Software, O=Delochi, L=Kun Ming, ST=Yun Nan, C=CN   
  34. //Serial number: 88072b9504be8f71   
  35. //Valid from: Thu Jan 13 07:51:29 CST 2011 until: Fri Jan 13 07:51:29 CST 2012   
  36. //Certificate fingerprints:   
  37. //    MD5:  DF:7F:54:4F:B3:A7:63:B3:74:31:5E:B6:29:F5:1E:E6   
  38. //    SHA1: 02:24:E2:1B:57:C1:38:F5:D3:31:76:D9:6C:71:15:44:56:BE:06:11   
  39. //    Signature algorithm name: SHA1withRSA   
  40. //    Version: 1   
  41. //Trust this certificate? [no]:  y   
  42. //Certificate was added to keystore   
  43. //[Storing /usr/java/jdk1.6.0_23/jre/lib/security/cacerts]   
  44. # keytool -alias delochi_ca_root -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit   
  45. //Alias name: delochi_ca_root   
  46. //Creation date: Jan 13, 2011   
  47. //Entry type: trustedCertEntry   
  48. //Owner: CN=Delochi CA Root, OU=Software, O=Delochi, L=Kun Ming, ST=Yun Nan, C=CN   
  49. //Issuer: CN=Delochi CA Root, OU=Software, O=Delochi, L=Kun Ming, ST=Yun Nan, C=CN   
  50. //Serial number: 88072b9504be8f71   
  51. //Valid from: Thu Jan 13 07:51:29 CST 2011 until: Fri Jan 13 07:51:29 CST 2012   
  52. //Certificate fingerprints:   
  53. //   MD5:  DF:7F:54:4F:B3:A7:63:B3:74:31:5E:B6:29:F5:1E:E6   
  54. //   SHA1: 02:24:E2:1B:57:C1:38:F5:D3:31:76:D9:6C:71:15:44:56:BE:06:11   
  55. //   Signature algorithm name: SHA1withRSA   
  56. //   Version: 1  

第二步,用CA去签发tomcat

  1. #  keytool -genkey -alias tomcat_server -validity 365 -keyalg RSA -keysize 1024 -keystore server_keystore   
  2. //Enter keystore password:123456   
  3. //Re-enter new password:123456   
  4. //What is your first and last name?   
  5. //  [Unknown]:  192.168.1.211   
  6. //What is the name of your organizational unit?   
  7. //  [Unknown]:  SoftWare   
  8. //What is the name of your organization?   
  9. //  [Unknown]:  Delochi   
  10. //What is the name of your City or Locality?   
  11. //  [Unknown]:  Kun Ming   
  12. //What is the name of your State or Province?   
  13. //  [Unknown]:  Yun Nan   
  14. //What is the two-letter country code for this unit?   
  15. //  [Unknown]:  CN   
  16. //Is CN=192.168.1.211, OU=SoftWare, O=Delochi, L=Kun Ming, ST=Yun Nan, C=CN correct?   
  17. //  [no]:  y   
  18. //Enter key password for <tomcat_server>   
  19. //        (RETURN if same as keystore password):123456   
  20. //Re-enter new password:123456   
  21. # keytool -certreq -alias tomcat_server -sigalg MD5withRSA -file server.csr  -keystore server_keystore   
  22. //Enter keystore password:123456   
  23. # openssl x509 -req -in server.csr -out server-cert.pem -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -days 365  
  24. //Signature ok   
  25. //subject=/C=CN/ST=Yun Nan/L=Kun Ming/O=Delochi/OU=SoftWare/CN=192.168.1.211   
  26. //Getting CA Private Key   
  27. # keytool -import -v -trustcacerts -alias tomcat_server -file server-cert.pem -keystore server_keystore   
  28. //Enter keystore password:  123456   
  29. //Certificate reply was installed in keystore   
  30. //[Storing server_keystore]  
linux
【内容导航】
第1页:Java环境配置 第2页:Tomcat的安装
第3页:Tomcat SSL的配置 第4页:修改Tomcat的默认主页
相关资讯       CentOS 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款