编程小贴士

给你的编程提供小点子


利用tomcat服务器配置https双向认证

首先请保证已经安装好jdk,并且环境变量以及配置好了

 

第一步、为服务器生成证书:

        使用toolkey为tomcat生成证书,假定目标机器的域名为localhost,使用如下命令生成:keytool –genkey –v –aliaslocalhost_server RSA –keystore localhost_server.store  –validity 36500

tips1000_2014-07-08_00-14-1

 

第二步、为客户端生成证书:

       为浏览器生成证书,以便让服务器来验证它。为了能保证证书顺利导入至IE和Firefox,证书格式应该是PKCS12,因此,使用如下命令生成:keytool –genkey –v –aliaslocalhost_client –keyalg RSA –storetype PKCS12 –keystore localhost_client.p12。这样就产生了localhost_client.p12文件,我们只需双击localhost_client.p12文件,即可将证书导入到浏览器(客户端)。

tips1000_2014-07-08_00-14-0

 

第三步、让服务器信任客户端证书:

       由于是双向的SSL认证,服务器必须信任客户端证书,因此,必须要把客户端证书添加为服务器的信任证书。由于不能直接将PKCS12格式的证书导入,必须先把客户端证书导出为一个单独的CER文件,使用如下命令:keytool –export –aliaslocalhost_client–keystore localhost_client.p12 –storetype –storepass 123456 –rfc–file localhost_trust.cer。下一步,是将该文件导入到服务器的证书库,添加一个信任证书,使用如下命令:keytool –import –v –filelocalhost_trust.cer –keystore localhost_server.store

tips1000_2014-07-08_00-14-1

通过list命令查看服务器的证书库,可以看到有两个证书,一个是服务器的证书,一个是受信任的客户端证书。

 

第四步、让客户端信任服务器证书:

       由于是双向SSL认证,客户端也要验证服务器证书,因此,必须把服务器证书添加到浏览器的“受信任的根证书颁发机构”。由于不能直接将keystore格式的证书库导入,必须先把服务器证书导出为一个单独的CER文件,使用如下命令:keytool –keystorelocalhost_server.store –export –alias localhost_server –file localhost_trust.cer。这样就产生了locahost_server.cer文件,我们只需双击localhost_server.cer文件,按照提示安装证书,将证书填入到“受信任的根证书颁发机构”。

tips1000_2014-07-08_00-14-11

 

第五步、配置tomcat服务器

       打开tomcat根目录下的/conf/server.xml,找到Connector port=“8443”配置段,修改为如下:

 
<ConnectorportConnectorport="8443"protocol="org.apache.coyote.http11.Http11NioProtocol"
SSLEnabled="true"maxThreads="150" scheme="https"
 
secure="true"clientAuth="true" sslProtocol="TLS"
 
keystoreFile="conf/localhost_server.keystore " keystorePass="123456"
 
truststoreFile="conf/localhost_server.keystore " truststorePass="123456" />
 
 
 
<ConnectorportConnectorport="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150"scheme="https" secure="true"
 
clientAuth="false"sslProtocol="TLS"
 
keystoreFile="conf/localhost_server.keystore"keystorePass="123456"
 
truststoreFile="conf/localhost_server.keystore"truststorePass="123456"/>

(tomcat要与生成的服务端证书名一致)

属性说明:

clientAuth:设置是否双向验证,默认为false,设置为true代表双向验证

keystoreFile:服务器证书文件路径

keystorePass:服务器证书密码

truststoreFile:用来验证客户端证书的根证书,此例中就是服务器证书

truststorePass:根证书密码

第六步、测试:

       在浏览器中输入:https://localhost:8443/,会弹出选择客户端证书界面,点击“确定”,会进入tomcat主页,地址栏后会有 “锁”图标,表示本次会话已经通过HTTPS双向验证,接下来的会话过程中所传输的信息都已经过SSL信息加密。

 

最后给大家看看效果图,免得大家觉得有问题:

tips3000_3034-07-08_00-34-33

tips2000_2024-07-08_00-24-22

178 Responses to “ 利用tomcat服务器配置https双向认证 ”

  1. best pron说道:

    a4IYV8 Wow! This could be one particular of the most beneficial blogs We have ever arrive across on this subject. Actually Excellent. I am also an expert in this topic so I can understand your effort.

  2. Pretty! This was a really wonderful article. Thank you for supplying this info.

  3. giay cao got dep说道:

    indeed, research is having to pay off. sure, study is having to pay off. My personal web surfing seem total.. thank you. I appreciate you showing your point of view..

  4. animal porn说道:

    Thanks again for the post.Much thanks again. Really Great.

  5. Pretty! This has been an extremely wonderful post. Thank you for supplying this information.

  6. animal coloring说道:

    not only should your roof protect you from the elements.

  7. Lung Health说道:

    Im grateful for the article post.Really looking forward to read more. Cool.

  8. Thank you for your post.Really thank you! Cool.

  9. There as certainly a great deal to know about this subject. I really like all of the points you ave made.

  10. Oluwadamilare说道:

    Wow, this paragraph is fastidious, my sister is analyzing such things, thus I am going to convey her.

  11. viagra dosage说道:

    Im inquisitive should any individual ever endure what individuals post? The web never was like which, except in which recently it as got become much better. What do you think?

  12. home说道:

    Regards for helping out, wonderful information. Nobody can be exactly like me. Sometimes even I have trouble doing it. by Tallulah Bankhead.

  13. Im thankful for the post.Thanks Again. Great.

  14. Mca scam说道:

    You can certainly see your enthusiasm within the work you write. The sector hopes for more passionate writers like you who are not afraid to mention how they believe. All the time follow your heart.

  15. Im grateful for the blog.Thanks Again. Cool.

  16. I truly appreciate this post.Thanks Again. Great.

  17. Ep coc 250x250说道:

    Thank you for your article post.Thanks Again. Really Great.

  18. private Hire说道:

    Very good blog post.Really thank you! Will read on

  19. Hosting Reviews说道:

    Thanks for sharing, this is a fantastic blog post. Want more.

  20. This blog is really awesome and diverting. I have found many helpful stuff out of it. I ad love to return again soon. Cheers!

  21. So pleased to possess located this post.. My browsing efforts seem total.. thanks. Liking the article.. appreciate it Respect the entry you furnished..

  22. This awesome blog is obviously interesting and diverting. I have chosen many interesting advices out of it. I ad love to visit it again soon. Thanks a bunch!

  23. see说道:

    pretty handy material, overall I consider this is worthy of a bookmark, thanks

  24. The Lost Ways说道:

    It as onerous to search out educated individuals on this topic, however you sound like you know what you are speaking about! Thanks

  25. You have made some decent points there. I checked on the internet for more information about the issue and found most individuals will go along with your views on this web site.

  26. Im obliged for the blog article.Thanks Again. Fantastic.

  27. Share说道:

    The information and facts talked about within the post are some of the top out there

  28. When I look at your blog in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping.

  29. More Bonuses说道:

    Many thanks for sharing this first-class article. Very interesting ideas! (as always, btw)

  30. Nwokolo说道:

    Simply a smiling visitant here to share the love (:, btw great design.

  31. Im thankful for the article.Thanks Again. Much obliged.

  32. klm coupon code说道:

    Pierre signe astrologique horoscope septembre balance Here is my homepage; voyance en ligne gratuite

  33. Muchos Gracias for your blog post. Cool.

  34. Utterly composed subject material, appreciate it for entropy. No human thing is of serious importance. by Plato.

  35. metal recycling说道:

    Well I definitely liked reading it. This tip procured by you is very effective for accurate planning.

  36. Eminem说道:

    Your kindness shall be tremendously appreciated.

  37. lien ke thanh ha说道:

    Thanks-a-mundo for the article post.Much thanks again. Will read on

  38. Woman of Alien Great work you have got carried out, this site is admittedly interesting with great facts. Time is God as method of retaining everything from going on at once.

  39. Say, you got a nice blog article. Want more.

  40. I think other website proprietors should take this site as an model, very clean and wonderful user genial style and design, as well as the content. You are an expert in this topic!

  41. more info说道:

    Thanks a lot for the blog post.Much thanks again. Keep writing.

  42. Roulette Table Planer! Bygg din egen Casino!

  43. Utterly indited content , appreciate it for entropy.

  44. You, my pal, ROCK! I found just the information I already searched all over the place and simply could not find it. What a great web site.

  45. Really informative blog article.Really thank you! Want more.

  46. Wow, amazing blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is wonderful, let alone the content!. Thanks For Your article about sex.

  47. web browsers and both show the same outcome.

  48. I visit every day a few sites and information sites to read articles or reviews, however this webpage provides feature based writing.

  49. This is one awesome article.Much thanks again. Really Great.

  50. Whoa! This blog looks just like my old one! It as on a completely different subject but it has pretty much the same layout and design. Wonderful choice of colors!

  51. Online说道:

    It as not that I want to replicate your web-site, but I really like the style. Could you let me know which theme are you using? Or was it custom made?

  52. Elena Matei说道:

    who you are however definitely you are going to a well-known blogger should you

  53. share说道:

    Wow! This could be one particular of the most beneficial blogs We ave ever arrive across on this subject. Actually Great. I am also an expert in this topic therefore I can understand your hard work.

  54. fitness说道:

    This unique blog is really cool and also diverting. I have found helluva useful advices out of this amazing blog. I ad love to visit it every once in a while. Cheers!

  55. It has been a long time since I ave read anything so informative and compelling. I am waiting for the next article from the writer. Thank you.

  56. visit website说道:

    It as not all on Vince. Folks about him ended up stealing his money. Also when you feel his professional career is more than, you are an idiot.

  57. Lovely website! I am loving it!! Will be back later to read some more. I am bookmarking your feeds also

  58. visit website说道:

    Regards for helping out, excellent information.

  59. Thanks for sharing, this is a fantastic blog article.Really thank you! Want more. this link

  60. I wanted to thank you for this great write-up, I certainly loved every small bit of it. I ave bookmarked your internet site to look at the newest stuff you post.

  61. Crochet poncho说道:

    knee injury. California will be looking to manage the ball

  62. Ganchillo说道:

    This is one awesome post.Thanks Again. Really Great.

  63. try this说道:

    Woh I like your content , saved to favorites !.

  64. white shoes说道:

    It’а†s in reality a nice and useful piece of info. I am glad that you just shared this useful info with us. Please stay us up to date like this. Thank you for sharing.

  65. value说道:

    You should be a part of a contest for one of the finest blogs on the internet. I am going to recommend this site!

  66. to learn more说道:

    There is evidently a bundle to realize about this. I consider you made various good points in features also.

  67. Pretty nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again soon!

  68. Thank you ever so for you blog.Really thank you! Great.

  69. Tel Aviv Escorts说道:

    Womens Ray Ban Sunglasses Womens Ray Ban Sunglasses

  70. School news说道:

    Where can I find legitimate blogs that are focused on or at least delve seriously into penis enlargement?

  71. Waec exam说道:

    I truly appreciate this article.Really thank you! Will read on

  72. ps4 ark servers说道:

    Thanks for the blog article.Really looking forward to read more. Really Great.

  73. Way cool! Some extremely valid points! I appreciate you writing this article plus the rest of the site is really good.

  74. It is faultless and I am glad that I visited this blog.

  75. Really enjoyed this blog.Thanks Again. Really Great.

  76. It’а†s actually a cool and helpful piece of info. I am happy that you just shared this helpful information with us. Please stay us up to date like this. Thanks for sharing.

  77. click here说道:

    Only wanna input that you have a very nice web site , I the design and style it actually stands out.

  78. trang tri tet说道:

    Vilma claimed that the cheap jersey problems of hackers to emails.

  79. Im obliged for the blog.Really thank you! Really Cool.

  80. Im obliged for the blog article.Much thanks again. Will read on

  81. Wow, awesome blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is great, as well as the content!

  82. scary maze说道:

    Wow, amazing blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is wonderful, as well as the content!. Thanks For Your article about sex.

  83. Thank you ever so for you blog post.Really looking forward to read more. Want more.

  84. Thank you for the post. I will definitely return.

  85. Im obliged for the blog post.Thanks Again. Great.

  86. cris urzua说道:

    I surprised with the research you made to create this actual publish amazing.

  87. You have made some decent points there. I looked on the web for additional information about the issue and found most individuals will go along with your views on this web site.

  88. It as hard to find knowledgeable people about this topic, but you

  89. share说道:

    yay google is my king assisted me to find this outstanding website !.

  90. traveler说道:

    I truly appreciate this post. I ave been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again!

  91. Open Heaven说道:

    Perfectly indited content material, appreciate it for entropy. The earth was made round so we would not see too far down the road. by Karen Blixen.

  92. Thanks a lot for the post.Much thanks again. Really Great.

  93. for more info说道:

    Wow! This could be one particular of the most useful blogs We have ever arrive across on this subject. Actually Wonderful. I am also an expert in this topic therefore I can understand your hard work.

  94. Pink your website post and cherished it. Have you at any time imagined about guest putting up on other relevant weblogs comparable to your website?

  95. Your current article usually have got a lot of really up to date info. Where do you come up with this? Just stating you are very imaginative. Thanks again

  96. Really enjoyed this blog.Really looking forward to read more. Keep writing.

  97. This is a good tip especially to those new to the blogosphere. Simple but very precise info Many thanks for sharing this one. A must read article!

  98. These online stores offer a great range of Chaussure De Foot Pas Cher helmet

  99. isabel marant sneakers pas cher isabel marant sneakers pas cher

  100. This very blog is no doubt entertaining and besides diverting. I have picked helluva helpful tips out of this source. I ad love to go back every once in a while. Thanks a bunch!

  101. Ceola说道:

    Thanks for the article.Thanks Again. Really Cool.

  102. go there说道:

    Touche. Great arguments. Keep up the great effort.

  103. click here说道:

    Thanks so much for the blog post. Fantastic.

  104. The loans may also be given at very strict terms as well as any violations will attract huge penalties super real property tax

  105. click here说道:

    Wow, amazing blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is fantastic, as well as the content!

  106. like this说道:

    There is perceptibly a bunch to know about this. I believe you made some good points in features also.

  107. for details说道:

    Really enjoyed this article post.Much thanks again. Will read on

  108. This is one awesome blog post.Really looking forward to read more. Keep writing.

  109. This is one awesome post.Thanks Again. Fantastic.

  110. You created some decent points there. I looked on the net for that challenge and discovered most of the people will go coupled with with all of your internet site.

  111. Perfectly written written content, Really enjoyed looking at.

  112. Wow! This can be one particular of the most useful blogs We have ever arrive across on this subject. Actually Great. I am also an expert in this topic so I can understand your hard work.

  113. Thanks for all аАааБТ“our vаА аЂаluablаА аЂа• laboаА аБТ– on this ?аА аЂа•bsite.

  114. social说道:

    I welcome all comments, but i am possessing problems undering anything you could be seeking to say

  115. twitter说道:

    Very good post.Really thank you! Keep writing.

  116. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You ave made my day! Thank you again

  117. I think this is a real great blog article.Really looking forward to read more. Awesome.

  118. bakedcomfortfood说道:

    Usually games carry interesting activities for

  119. Nice post. I learn something new and challenging on blogs I

  120. Really appreciate you sharing this blog.Thanks Again. Really Great.

  121. Some genuinely interesting information, well written and generally user friendly.

  122. visit website说道:

    Its hard to find good help I am forever saying that its difficult to find quality help, but here is

  123. You made some decent points there. I looked on the internet for the subject and found most guys will consent with your blog.

  124. clickhere说道:

    Thanks so much for the blog post.Really looking forward to read more. Really Cool.

  125. I was same pleased to find this website. I wanted to thank you for your calculate representing this admirable post!!

  126. dong ho seiko 5说道:

    Say, you got a nice article post.Much thanks again. Much obliged.

  127. Outstanding post however , I was wanting to know if you could write a litte more on this subject? I ad be very thankful if you could elaborate a little bit more. Thank you!

  128. official site说道:

    Many thanks for sharing this first-class post. Very inspiring! (as always, btw)

  129. more info说道:

    You realize so much its almost hard to argue with you (not that I actually will need toHaHa).

  130. Woman of Alien Best get the job done you have got performed, this website is admittedly interesting with wonderful facts. Time is God as way of retaining every thing from taking place at once.

  131. lawyer miami fl说道:

    Major thankies for the blog article.Thanks Again.

  132. I truly appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You ave made my day! Thx again

  133. click here说道:

    I value the article.Thanks Again. Much obliged.

  134. sunday说道:

    you ave got an amazing blog right here! would you like to make some invite posts on my weblog?

  135. site. It as simple, yet effective. A lot of times it as very

  136. Sources Wow! Thank you! I always needed to write on my blog something like that. Can I implement a fragment of your post to my blog?

  137. Bandar Ceme说道:

    Wow! This could be one particular of the most helpful blogs We have ever arrive across on this subject. Basically Great. I am also an expert in this topic so I can understand your effort.

  138. Really enjoyed this post.Thanks Again. Will read on

  139. This very blog is obviously awesome and also informative. I have chosen a lot of interesting things out of this amazing blog. I ad love to return over and over again. Thanks a bunch!

  140. Ultimately, an issue that I am passionate about. I have looked for information of this caliber for the very last numerous hours. Your site is greatly appreciated.

  141. You made some respectable points there. I looked on the internet for the difficulty and found most individuals will go together with together with your website.

  142. Really appreciate you sharing this post.Really looking forward to read more. Really Great.

  143. This very blog is no doubt interesting as well as amusing. I have picked up a bunch of useful advices out of this blog. I ad love to go back every once in a while. Thanks!

  144. Game Online说道:

    veux garder ta que le monde tot il marchait, je ne

  145. The Zune concentrates on being a Portable Media Player. Not a web browser. Not a game machine.

  146. I value the article post.Much thanks again. Really Cool.

  147. Muchos Gracias for your article. Want more.

  148. check out说道:

    Rattling superb info can be found on website.

  149. state. This is the first time I frequented your web page and up to now?

  150. So happy to get found this submit.. Is not it terrific once you obtain a very good submit? Great views you possess here.. My web searches seem total.. thanks.

  151. live casino说道:

    I simply could not go away your website before suggesting that I really enjoyed the standard info an individual provide to your visitors? Is gonna be back continuously to inspect new posts

  152. that is the end of this write-up. Right here you

  153. Your style is so unique in comparison to other people I ave read stuff from. I appreciate you for posting when you have the opportunity, Guess I all just book mark this site.

  154. safe power leveling and gold I feel pretty lucky to have used your entire website page and look forward to many more excellent times reading here

  155. This is one awesome blog article.Thanks Again. Really Great.

  156. I truly appreciate this blog article.Really looking forward to read more. Want more.

  157. bo dam说道:

    Thanks for sharing, this is a fantastic article.Really thank you! Cool.

  158. You ave made some good points there. I checked on the web for more info about the issue and found most people will go along with your views on this website.

  159. I truly appreciate this blog post. Much obliged.

  160. site web说道:

    very good submit, i definitely love this web site, carry on it

  161. uniform stores说道:

    I wanted to thank you for this fantastic write-up, I certainly loved every little bit of it. I have bookmarked your internet site to look at the latest stuff you post.

  162. Very nice article and straight to the point. I don at know if this is actually the best place to ask but do you folks have any thoughts on where to employ some professional writers? Thanks

  163. Right now it appears like WordPress is the top blogging platform out there right now. (from what I ave read) Is that what you are using on your blog?

  164. Thank you ever so for you blog post.Really looking forward to read more.

  165. best pron说道:

    owHBNf I truly enjoy looking at on this website , it contains fantastic articles.

  166. Thanks a lot for the article post.Much thanks again. Much obliged.

  167. There as a lot of folks that I think would really enjoy your content.

  168. Really enjoyed this post.Thanks Again. Great.

  169. Just wanna say that this is very useful , Thanks for taking your time to write this.

  170. There is noticeably a bundle to identify about this. I feel you made various nice points in features also.

  171. This post is invaluable. When can I find out more?

  172. Thanks for the blog post.Much thanks again. Much obliged.

  173. You have brought up a very excellent details, appreciate it for the post.

  174. check out说道:

    Thank you, I have just been looking for info about this subject for ages and yours is the best I have discovered so far. But, what about the bottom line? Are you sure about the source?

  175. Merely wanna state that this is very helpful , Thanks for taking your time to write this.

  176. Woh I enjoy your content , saved to bookmarks!

  177. Really appreciate you sharing this blog post.Much thanks again. Really Great.

  178. bistro masa说道:

    Im obliged for the article post.Really looking forward to read more. Really Cool.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>