为 Android 程序创建 CA keystore 以及 self-signed keystore 的方法 - yanbin's Blog

为 Android 程序创建 CA keystore 以及 self-signed keystore 的方法

yanbin posted @ 2015年3月29日 18:36 in Networking with tags programming Networking , 12229 阅读
为什么 Android 程序需要 CA KeyStore?
1. 在 Android 程序中建立一条 SSL/TLS 连接时,受信任 CA (Trusted CAs) 用来验证 server。
    Public-Key Infrastructure (PKI) 中有 trust certs 概念,许多网络工具实现了 trusted CA 的使用。
    比如: curl, Android URLConnection.
    Android 系统中有一个 trusted CAs list, 包含 100 多个 trusted CAs.
  
2. 建立 SSL/TLS 连接时现有的 trusted CAs 不能验证服务器证书,会引发一个 security exception:
       javax.net.ssl.SSLHandshakeException: ... : Trust anchor for certification path not found.
   具体而言,以下这些情况会引发这个问题:
      (a) The CA that issued the server certificate was unknown;
      (b) The server certificate wasn't signed by a CA, but was self signed;
      (c) The server configuration is missing an intermediate CA;
 
3. 针对(a) 和 (b) 这两种情况,解决方法是创建 SSL/TLS 连接时使用 Android TurstManager 工具。
    在 Android 程序中 TrustManager 用 KeyStore instance 初始化,而 KeyStore instance 读取/解析
    BKS/JKS 格式的 KeyStore 文件,获得证书信息。
  
4. 使用 keytool 工具创建 BKS 格式的 KeyStore 文件。
    keytool 在多数 linux 发行版中都可以通过 package 管理工具获得。
    keytool 创建 BKS 格式的 KeyStore 文件需要用到 BouncyCastle Provider, 这个文件 JRE 不提供,
    keytool 本身也没有提供,需要下载后通过参数指定。创建 JKS 格式的 KeyStore 不用这个文件。
 
    $ keytool -importcert -v -trustcacerts -file "root-ca.crt" -alias root-ca -keystore "root-ca.bks"
       -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk16-145.jar"
       -storetype BKS -storepass zhelishimia
 
   验证 keystore 文件是否正确:
   $ keytool -list -keystore "root-ca.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider
     -providerpath "bcprov-jdk16-145.jar" -storetype BKS -storepass zhelishimima
 
5. 也可以直接用 server certificate 生成 keystore 并且设置为 trusted, 不过这样做不够安全,而且 server
    端的证书有改变时还需要生成新的证书。
  
 
有时也客户端程序也用证书标识自己的身份。或者有些 JAVA server 程序中建立 SSL 连接时用 KeyStore
提供证书信息。
1. 使用 openssl 工具转换 X509 格式的 public certificate 和 private key 为 pkcs12 格式的文件。
    $ openssl pkcs12 -export -in broker.crt -inkey broker.key -out broker.p12 -name client001
       -CAfile root-ca.crt -chain
 
2. 使用 openssl 工具和 pkcs12 文件生成 keystore
    $ keytool -importcert -v -trustcacerts -file "root-ca.crt" -alias root-ca -keystore "root-ca.bks"
       -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk16-145.jar"
       -storetype BKS -storepass 12345678
 
3. 在 Android 程序中, 建立一条 SSL 连接时可以用 KeyManager 工具指定本端的 public certificate,
    private key, KeyManager 需要用 KeyStore instace 初始化,KeyStore instance 加载/解析 keystore 文件,
    获取 public certificate 以及 private key 信息。
 
 
参考:

   

Avatar_small
pokemon go apk 说:
2017年1月22日 19:04

This is a very interesting web page and I have enjoyed reading many of the articles and posts contained on the website, keep up the good work and hope to read some more interesting content in the future.

Avatar_small
lolnexus 说:
2017年10月14日 14:24

It is a great article. You will surely like this also because it is a great stuff, yeah it’s give us lots of interest and pleasure. Their opportunities are so fantastic and working style so speedy. Thank you for sharing the nice article.

Avatar_small
blackmart 说:
2017年10月14日 14:25

Thank you for bringing more information to this topic for me. I’m truly grateful and really impressed. Absolutely this article is incredible..

Avatar_small
Buy a 314 Area code 说:
2018年7月19日 15:18

Buy a 314 Area code Number in usa

Avatar_small
we mobile price in b 说:
2018年10月18日 17:51

I am waiting for your next help post

Avatar_small
mobile price in bd 说:
2018年10月18日 17:53

it's a very interesting web page I will back

Avatar_small
unique girl names 说:
2018年10月23日 15:24

Thanks for sharing these useful information!

Avatar_small
Assignment help 说:
2018年10月27日 17:58

Students Assignment Help provides the services of customer psychology assignment help to the students.All Assignment Help is an online Assignment Help and assignment writing service offering expert assignment help.Hire Australian,US assignment writing experts.

Avatar_small
rolling sky 说:
2018年12月26日 10:33

I have a similar issue. I will try your solution and see if it works

Avatar_small
mpcsonline 说:
2019年3月28日 13:47

<a href="http://mpcs.online/2019/03/11/metropcs-payment/"> <b> MetroPCS Payment Online & Offline | MetroPCS Bill Pay Terms & Conditions </b> </a> Thank you for sharing! I hope you will continue to have great articles like this to share with everyone! <a href="http://mpcs.online/"> <b> Mpcs Online </b> </a>

Avatar_small
mpcsonline 说:
2019年3月28日 13:48

I found this blog very informative and interesting. Will look forward to more such posts http://mpcs.online/

Avatar_small
fireboy and watergir 说:
2019年4月16日 09:57

I think this is an informative post and it is very useful and knowledgeable. I really enjoyed reading this post. big fan, thank you!

Avatar_small
remove password 说:
2019年5月13日 22:23

good

Avatar_small
pcsmetrobytmobile 说:
2019年7月16日 15:16

<a href="https://pcsmetrobytmobile.online/metropcs-by-t-mobile-payment/"> <b> Metrobyt mobile payment </b> </a> I found this blog very informative and interesting. Will look forward to more such posts <a href="https://pcsmetrobytmobile.online/metropcs-payment/"> <b> MetroPCS payment </b> </a>

Avatar_small
mpcsonline 说:
2019年8月14日 18:30

<a href="https://mpcs.online/2019/03/09/metropcs-bill-pay/"> <b> MetroPCS Bill Pay | How To Pay MetroPCS Bill Online & Offline
</b> </a> Your article is very useful. it's really helpful and informative <a href="https://mpcs.online/2019/03/11/metropcs-payment/"> <b> MetroPCS Payment Online & Offline | MetroPCS Bill Pay Terms & Conditions
</b> </a>

Avatar_small
pcsmetrobytmobile 说:
2019年8月14日 18:37

<a href=”https://pcsmetrobytmobile.online/metropcs-by-t-mobile-payment/”> <b> Metrobyt mobile payment
</b></a> Very interesting, good job and thanks for sharing such a good blog <a href=”https://pcsmetrobytmobile.online/metropcs-payment/”> <b> MetroPCS payment
</b></a>

Avatar_small
KOKO 说:
2019年8月21日 17:57

hello,
Your Site is very nice, and it's very helping us this post is unique and interesting, thank you for sharing this awesome information. and visit our blog site also
<a href="https://sattakingdarbar.com/">Satta King</a>

Avatar_small
KOKO 说:
2019年8月21日 17:58

hello,
Your Site is very nice, and it's very helping us this post is unique and interesting, thank you for sharing this awesome information. and visit our blog site also
<a href="https://sattakingdarbar.com/">Satta King</a>

https://sattakingdarbar.com/

Avatar_small
toto212 说:
2019年8月31日 16:55

Togel212 adalah Bandar Togel Online Terpercaya yang menyediakan berbagai macam permainan terbaik dan terlengkap seperti Togel SGP, Togel HKG, Togel Sydney dan Magnum4D. Togel212 juga merupakan Situs Judi Casino Online Terpercaya dengan berbagai games Live Casino favorit seperti baccarat, roulette, blackjack dan sebagainya dengan real time streaming yang cepat.

Avatar_small
mpcsonline 说:
2019年9月12日 14:30

<a href=”https://mpcs.online/2019/03/09/metropcs-bill-pay/”> <b> MetroPCS Bill Pay | How To Pay MetroPCS Bill Online & Offline
</b> </a> Thanks for sharing Wonderful tips!! All are informative <a href=”https://mpcs.online/2019/03/11/metropcs-payment/”> <b> MetroPCS Payment Online & Offline | MetroPCS Bill Pay Terms & Conditions
</b> </a>

Avatar_small
run 3 说:
2019年11月06日 14:53

When I am surfing the web occasionally I have discovered a website this really is particularly thought to invoke such as this one. I wanted to share that I found the content on your website has been highly interesting and I learned new things. I will be sure to look for your upcoming post. Many thanks for this fantastic write-up I will come again soon.

Avatar_small
rajaremi 说:
2019年11月13日 14:35

rajaremi Poker Dengan teknologi terkini, poker kami menawarkan permainan seru dan kemenangan besar dimana konsepnya adalah pemain lawan pemain. poker online Seperti game online di handphone, anda bisa bermain dimana saja, kapan saja bahkan hanya dengan satu tangan. Pelajari lebih lanjut atau download aplikasi Poker kami sekarang baik di Android ataupun di iOS, meja yang cepat dan privasi terjamin menanti anda.

Avatar_small
indonbet 说:
2019年11月18日 13:11

indonbet merupakan sarana informasi tentang berbagai situs judi online seperti poker online,dan promo bonus bonus menarik dari situs yang sudah terpercaya di dunia betting online.

Avatar_small
rajaremi 说:
2019年11月24日 16:19

Thankyou for yet another amazing article. The spot may simply anybody get that kind of advice such an perfect way of creating? I've got a demonstration every week, also I'm looking for this particular advice.I'm very satisfied to get visited your page and then anticipate so a lot more interesting times . Thank you for the information

Avatar_small
Rajaremi 说:
2019年11月25日 13:34

rajaremi Poker Dengan teknologi terkini, poker kami menawarkan permainan seru dan kemenangan besar dimana konsepnya adalah pemain lawan pemain. poker online Seperti game online di handphone, anda bisa bermain dimana saja, kapan saja bahkan hanya dengan satu tangan. Pelajari lebih lanjut atau download aplikasi Poker kami sekarang baik di Android ataupun di iOS, meja yang cepat dan privasi terjamin menanti anda.

Avatar_small
poker88 说:
2019年12月12日 21:11

erima kasih masukkan keystore

Avatar_small
pokerdewa 说:
2019年12月12日 21:13

https://88pokerindo.com/
https://88pokerindo.com/category/poker-online/
https://88pokerindo.com/category/domino-online/
https://88pokerindo.com/category/capsa-online/
https://88pokerindo.com/category/panduan-bermain-judi/
https://88pokerindo.com/poker-88-indonesia/
https://88pokerindo.com/indowin99/
https://88pokerindo.com/satriapoker/
https://88pokerindo.com/daunpoker/
https://88pokerindo.com/gadispoker/
https://88pokerindo.com/cara-mendaftar-inulpoker-dan-link-alternatif-inul-poker-terbaik/
https://88pokerindo.com/sentapoker/
https://88pokerindo.com/babepoker-kelebihan-dan-kekurangan-judi-online-uang-asli/
https://88pokerindo.com/pokerfren-situs-poker-online-dengan-banyak-bonus/
https://88pokerindo.com/panduan-untuk-melakukan-pendaftaran-iopoker/
https://88pokerindo.com/kelebihan-situs-poker-terbaik-sarangdomino/
https://88pokerindo.com/page/2/
https://88pokerindo.com/page/3/
https://88pokerindo.com/poker88/
https://88pokerindo.com/category/poker-online/page/2/
https://88pokerindo.com/dominobet/
https://88pokerindo.com/ratucapsa/
https://88pokerindo.com/cara-bermain-omaha-poker/
https://88pokerindo.com/panduan-aduq-yang-harus-dipahami-sebelum-menikmati-gamenya/
https://88pokerindo.com/cara-main-super10/
https://88pokerindo.com/panduan-capsa-susun/
https://88pokerindo.com/bermain-judi-poker-online/
https://88pokerindo.com/panduan-dominoqq/
https://88pokerindo.com/bandar-poker/
https://88pokerindo.com/panduan-bandar66-dan-cara-perhitungan-kartunya/
https://88pokerindo.com/panduan-bandar-sakong-terpercaya-resmi-2020/
https://88pokerindo.com/dewapoker/
https://88pokerindo.com/senangpoker/
https://88pokerindo.com/jayapoker/

Avatar_small
rajaremi 说:
2019年12月30日 07:45

rajaremi merupakan agen terbaik Indonesia sudah direkomendasikan bagi para bettor ingin menikmati kepuasan permainan secara online. Dengan servis terbaik & server siap melayani pecinta judi full time selama 24 jam penuh. Dengan tampilan Rajaremi sangat menarik perhatian bagi pengguna, Rajaremi siap melayani bettor dengan baik. Rajaremi Agen Poker Online Terpercaya yang memiliki keamanan yang sangat terjaga, serta anda memainkan games secara lengkap hanya dengan 1 ID saja. Game yang dapat di mainkan, diantaranya poker, domino, capsa, ceme, omaha , ceme keliling and super10. ke tujuh game di mainkan sangat mudah menang bermain di Rajaremi, karena player mainkan pada smartphone pintar anda. Dimanapun bettor berada, pastinya pemain bisa mengakses permainan ini secara online. Beragam permainan agen tawarkan sangatlah nyaman, karena kepuasan user adalah visi utama kami. Rajaremi sangat mengutamakan kepuasan setiap bettor atau user bermain pada agen bandarq terpercaya. Maka kritik & saran anda sangatlah penting bagi kami, untuk segala keluhan serta kiritik maupun saran pemain langsung di sampaikan melalui media social yang telah kami sediakan live chat resmi untuk anda

Avatar_small
Dr Norton 说:
2020年5月08日 15:44

<a href="https://zeemalcrack.com/">Zeemal Crack</a>
<a href="https://protoolscrack.net/">Protool Crack</a>
<a href="https://zeemalcrack.com/driver-genius-pro-crack/">Driver genius Crack</a>
<a href="https://zeemalcrack.com/virtual-dj-pro-crack/">DJ pro Crack</a>
<a href="http://zeemalcrack.com/mrt-dongle-crack/">MRT Dongle Crack</a>
<a href="https://protoolscrack.net/vmix-crack-registration-key/">vMix Crack</a>
<a href="https://protoolscrack.net/miracle-thunder-crack/">Miracle Thunder Crack</a>
<a href="http://zeemalcrack.com/manycam-pro-crack/>ManyCAm Crack</a>
<a href="https://protoolscrack.net/virtual-dj-pro-crack/">Virtual DJ Pro Crack</a>

Avatar_small
Dr Norton 说:
2020年5月08日 15:44

https://protoolscrack.net
http://zeemalcrack.com

https://protoolscrack.net/miracle-thunder-crack/
https://protoolscrack.net/autotune-pro-crack/
https://protoolscrack.net/pro-tools-crack-avid-pro-tools-crack/
https://protoolscrack.net/z3x-samsung-tool-pro-crack/
https://protoolscrack.net/virtual-dj-pro-crack/
http://zeemalcrack.com/miracle-thunder-crack/
http://zeemalcrack.com/mrt-dongle-crack/
http://zeemalcrack.com/sigmakey-box-crack/
http://zeemalcrack.com/panda-free-antivirus-crack/
http://zeemalcrack.com/vray-crack/
https://zeemalcrack.com/virtual-dj-pro-crack/

Avatar_small
jordan 说:
2020年11月02日 20:53

Thank you for sharing excellent blog.if you are want not happy with your relationship consult our expert astrologer and get tips or astrology prediction regarding your relationship or enhance love in your life.

<a href="https://www.astroswamig.com/"> Best Astrologer</a>
<a href="https://www.astroswamig.com/">Astrologer for free</a>
<a href="https://www.astroswamig.com/talk-to-astrologers/">Talk To Astrologer</a>
<a href="https://www.astroswamig.com/">Free astrology predictions by date of birth </a>
<a href="https://www.astroswamig.com/articles/">Free-Astrology-Predictions</a>
<a href="https://www.astroswamig.com/hindi/">Aaj ka Rashifal</a>
<a href="https://www.astroswamig.com/articles/">Online Astrology-Predictions</a>
<a href="https://www.astroswamig.com/">Online Astrology Consultation</a>
<a href="https://www.astroswamig.com/free-kundli">Free kundli online</a>

Avatar_small
jordan 说:
2020年12月14日 18:32

Thank you for sharing such a informative blog.if you are suffering many problems in your life.get solutions or tips and astrology predictions of your problems from best astrologers of India for free on call or chat.

Avatar_small
casino courchevel 说:
2021年1月21日 22:14

You will find on these online casinos a wide range of games of all kinds, provided you choose a reliable casino that allows you to have opportunities to collect winnings, what to combine the useful with the pleasant.

Avatar_small
webpage 说:
2021年3月26日 00:27

I think this is an informative post and it is very useful and knowledgeable. I really enjoyed reading this post. big fan, thank you!

Avatar_small
Find the best Alexa 说:
2021年3月28日 16:30

I think this is an informative post and it is very useful and knowledgeable. I really enjoyed reading this post. big fan, thank you!

Avatar_small
madhu 说:
2021年3月29日 18:35

Ahaan wha ti great information shared here

Avatar_small
Alexa Ranking 说:
2021年4月01日 21:48

An obligation of appreciation is all together for such an unprecedented post and the review, I am totally propelled! Keep stuff like this coming.

Avatar_small
lemon law lawyer 说:
2021年4月11日 18:01

This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.

Avatar_small
rank your website 说:
2021年4月15日 12:34

This can be a excellent post, Many thanks with regard to providing me personally these details. Maintain publishing.

Avatar_small
안전놀이터 说:
2021年4月17日 00:03

These are some great tools that i definitely use for SEO work. This is a great list to use in the future..

Avatar_small
movies123 说:
2021年4月17日 18:29

You made some first rate points there. I appeared on the web for the difficulty and located most individuals will go along with together with your website.

Avatar_small
IDN Poker 说:
2021年4月17日 21:17

I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee