一、生成密钥库和证书

1、生成服务器证书库

keytool -validity 365 -genkey -v -alias uyun -keyalg RSA -keystore /opt/UEM/keyStore/uyun.keystore -dname "CN=192.168.16.163,OU=broada,O=broada,L=Hangzhou,ST=Hangzhou,c=cn" -storepass uyuncollector -keypass uyuncollector

2、生成客户端证书库

keytool -validity 365 -genkeypair -v -alias client -keyalg RSA -storetype PKCS12 -keystore /opt/UEM/keyStore/client.p12 -dname "CN=client,OU=broada,O=broada,L=hangzhou,ST=hangzhou,c=cn" -storepass uyuncollector -keypass uyuncollector

3、从客户端证书库中导出客户端证书

keytool -export -v -alias client -keystore /opt/UEM/keyStore/client.p12 -storetype PKCS12 -storepass uyuncollector -rfc -file /opt/UEM/keyStore/client.cer

4、从服务器证书库中导出服务端证书

keytool -export -v -alias uyun -keystore /opt/UEM/keyStore/uyun.keystore -storepass uyuncollector -rfc -file /opt/UEM/keyStore/uyun.cer

5、生成客户端信任证书库(由服务端证书生成的证书库)

命令:

keytool -import -v -alias uyun -file /opt/UEM/keyStore/uyun.cer -keystore /opt/UEM/keyStore/client.truststore -storepass uyuncollector

成功结果:

[root@uem bin]# keytool -import -v -alias uyun -file /opt/UEM/keyStore/uyun.cer -keystore /opt/UEM/keyStore/client.truststore -storepass uyuncollector
Owner: CN=192.168.16.163, OU=broada, O=broada, L=Hangzhou, ST=Hangzhou, C=cn
Issuer: CN=192.168.16.163, OU=broada, O=broada, L=Hangzhou, ST=Hangzhou, C=cn
Serial number: 21210db8
Valid from: Wed Jul 15 11:39:18 CST 2015 until: Thu Jul 14 11:39:18 CST 2016
Certificate fingerprints:
MD5: 82:37:F3:44:19:93:94:A5:E7:6A:60:3A:AA:CF:8B:80
SHA1: 17:A6:24:A4:3D:0B:D3:8F:50:5A:8E:91:E8:1D:23:72:6C:D1:3D:38
SHA256: F0:A9:EC:85:06:64:E9:5D:D6:7B:65:9C:40:7D:DF:2C:C1:B5:41:08:CC:86:E1:1B:4A:3A:A3:0C:E2:F1:44:41
Signature algorithm name: SHA256withRSA
Version: 3 Extensions: #1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 02 E6 CD 31 BE F0 54 84 D1 B5 A3 E7 DC 2E 03 5B ...1..T........[
0010: F2 22 05 0D ."..
]
] Trust this certificate? [no]: y
Certificate was added to keystore
[Storing /opt/UEM/keyStore/client.truststore]

6、将客户端证书导入到服务器证书库(使得服务器信任客户端证书)

keytool -import -v -alias client -file /opt/UEM/keyStore/client.cer -keystore /opt/UEM/keyStore/uyun.keystore -storepass uyuncollector

成功结果:

[root@uem bin]# keytool -import -v -alias client -file /opt/UEM/keyStore/client.cer -keystore /opt/UEM/keyStore/uyun.keystore -storepass uyuncollector
Owner: CN=client, OU=broada, O=broada, L=hangzhou, ST=hangzhou, C=cn
Issuer: CN=client, OU=broada, O=broada, L=hangzhou, ST=hangzhou, C=cn
Serial number: 2dac5990
Valid from: Wed Jul 15 11:44:12 CST 2015 until: Thu Jul 14 11:44:12 CST 2016
Certificate fingerprints:
MD5: 8B:80:CE:DB:5A:1A:B7:91:0F:46:93:1C:82:03:C6:7C
SHA1: 7D:6B:1E:68:7D:9E:04:8B:B4:12:51:61:89:46:56:06:C2:50:5C:94
SHA256: 25:FE:36:79:7E:0C:9A:9F:DD:95:DB:92:82:C1:FC:C1:BD:BB:6B:05:D8:84:52:33:FE:5F:8D:25:23:00:E0:86
Signature algorithm name: SHA256withRSA
Version: 3 Extensions: #1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: C4 52 CC CC 7A B0 B5 CA B6 CF E1 F9 53 7E 91 69 .R..z.......S..i
0010: 03 1C B2 69 ...i
]
] Trust this certificate? [no]: y
Certificate was added to keystore
[Storing /opt/UEM/keyStore/uyun.keystore]

7、查看证书库中的全部证书:

keytool -list -keystore /opt/UEM/keyStore/uyun.keystore -storepass uyuncollector

结果:

[root@uem bin]# keytool -list -keystore /opt/UEM/keyStore/uyun.keystore -storepass uyuncollector

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 2 entries

client, Jul 15, 2015, trustedCertEntry,
Certificate fingerprint (SHA1): 7D:6B:1E:68:7D:9E:04:8B:B4:12:51:61:89:46:56:06:C2:50:5C:94
uyun, Jul 15, 2015, PrivateKeyEntry,
Certificate fingerprint (SHA1): 17:A6:24:A4:3D:0B:D3:8F:50:5A:8E:91:E8:1D:23:72:6C:D1:3D:38

使用HttpClient进行https连接(一)的更多相关文章

  1. httpclient调用https

    httpclient调用https报错: Exception in thread "main" java.lang.Exception: sun.security.validato ...

  2. 使用HttpClient发送HTTPS请求以及配置Tomcat支持SSL

    这里使用的是HttpComponents-Client-4.1.2 package com.jadyer.util; import java.io.File; import java.io.FileI ...

  3. android httpClient 支持HTTPS的2种处理方式

    摘自: http://www.kankanews.com/ICkengine/archives/9634.shtml 项目中Android https或http请求地址重定向为HTTPS的地址,相信很 ...

  4. Httpclient 支持https(转)

    参考:https://jingyan.baidu.com/article/154b46317353d228ca8f4112.html 参考:https://www.jianshu.com/p/a444 ...

  5. https连接的前几毫秒发生了什么

    在讨论这个话题之前,先提几个问题: 为什么说https是安全的,安全在哪里? https是使用了证书保证它的安全的么? 为什么证书需要购买? 我们先来看https要解决什么问题 (手机读者推荐移步ht ...

  6. Python中HTTPS连接

    permike 原文 Python中HTTPS连接 今天写代码时碰到一个问题,花了几个小时的时间google, 首先需要安装openssl,更新到最新版本后,在浏览器里看是否可访问,如果是可以的,所以 ...

  7. c# 中HttpClient访问Https网站

    c# 中HttpClient访问Https网站,加入如下代码: handler = new HttpClientHandler() ;handler.AllowAutoRedirect = true; ...

  8. httpclient的并发连接问题

    昨天的搜索系统又出状况了,几个库同时重建索引变得死慢.经过一个上午的复现分析,确定问题出现httpclient的使用上(我使用的是3.1这个被广泛使用的遗留版本).搜索系统在重建索引时,是并发多个线程 ...

  9. java ssl https 连接详解 生成证书 tomcat keystone

    java ssl https 连接详解 生成证书 我们先来了解一下什么理HTTPS 1. HTTPS概念 1)简介 HTTPS(全称:Hypertext Transfer Protocol over ...

随机推荐

  1. Mybatis源码之Statement处理器SimpleStatementHandler(四)

    SimpleStatementHandler就是使用基本的Statement来执行query.batch.update等操作,其实现还是比较简单的,当然在执行过程中会涉及keyGenerator和Re ...

  2. 1025. PAT Ranking (25)

    题目如下: Programming Ability Test (PAT) is organized by the College of Computer Science and Technology ...

  3. UICollectionView请求网络数据显示(Text)

    TEXT: AppDelegate.m self.window.rootViewController = [[[UINavigationController alloc]initWithRootVie ...

  4. Android开机键失灵启动手机的解决办法

    问题描述 Android手机的关机键损坏,无法开机. 解决方法 将手机通过USB线链接电脑,进入命令行,找到adb命令所在目录,运行如下命令: adb reboot 注意:用这种方法的前提是,如果你当 ...

  5. 11.3、Libgdx的音频之播放PCM音频

    (官网:www.libgdx.cn) audio模块可以提供对音频硬件的直接访问. 音频硬件是通过AudioDevice接口进行的抽象. 以下创建一个新的AudioDevice实例: AudioDev ...

  6. C语言的预编译

    由"源代码"到"可执行文件"的过程包括四个步骤:预编译.编译.汇编.链接.所以,首先就应该清楚的首要问题就是:预编译只是对程序的文本起作用,换句话说就是,预编译 ...

  7. Google的两种广告推广方式

    1搜索关键字广告推送:AdWords: 覆盖广泛:在全球最大的搜索和网络平台上进行推广. 定位精准:锁定目标客户群体,让潜在客户轻松找上门. 成本可控:仅当用户点击广告时,您才支付费用. 2.网站内容 ...

  8. javascript语法之函数的定义

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. AngularJS进阶(三十六)AngularJS项目开发技巧之利用Service&Promise&Resolve解决图片预加载问题(后记)

    AngularJS项目开发技巧之利用Service&Promise&Resolve解决图片预加载问题(后记) 前言 在"AngularJS项目开发技巧之图片预加载" ...

  10. LeetCode之“链表”:Partition List

    题目链接 题目要求: Given a linked list and a value x, partition it such that all nodes less than x come befo ...