Public Key Infrastructure(PKI)的基本概念和Certificate的创建
2013-03-22 15:51
323 查看
一.PKI的作用
公钥加密也叫做非对称加密,它用一对密钥来进行加密和解密,用某用户密钥加密后所得的信息,只能用该用户的解密密钥才能解密。如果知道了其中一个,并不能计算出另外一个。因此如果公开了一对密钥中的一个,并不会危害到另外一个的秘密性质。称公开的密钥为公钥;不公开的密钥为私钥。
在用户使用公钥加密时并不能确定使用的公钥的可信性,Public Key Infrastructure就是通过引入一个可信的第三方certification authority(CA)来确保公钥的完整性和持有人的身份。
二.X.509PKI的结构
X.509 public key infrastructure标准的结构如下
-- X.509 signed certificate
---------------------------------------------------------------------
SignedContent ::= SEQUENCE
{
certificate CertificateToBeSigned,
algorithm Object Identifier,
signature BITSTRING
}
---------------------------------------------------------------------
-- X.509 certificate to be signed
---------------------------------------------------------------------
CertificateToBeSigned ::= SEQUENCE
{
version [0] CertificateVersion DEFAULT v1,
serialNumber CertificateSerialNumber,
signature AlgorithmIdentifier,
issuer Name
validity Validity,
subject Name
subjectPublicKeyInfo SubjectPublicKeyInfo,
issuerUniqueIdentifier [1] IMPLICIT UniqueIdentifier OPTIONAL,
subjectUniqueIdentifier [2] IMPLICIT UniqueIdentifier OPTIONAL,
extensions [3] Extensions OPTIONAL
}
关于数据结构的更多信息见http://msdn.microsoft.com/en-us/library/bb540790(v=vs.85).aspx
三.Store certificate
如果需要用windows service权限访问certificate,则使用local machine store.需要管理员权限存。
如果是用户权限访问,则使用current user store
在MMC snap-in里查看数字证书
1.运行mmc。
2.在File目录下点Add/Remove Snap In
3.点Add加入想要查看的Certificates。
查看和Internet Explorer有关的数字证书
在Internet Options里面选Content tab里面的Certificates
四.创建certificate
可以用Windows SDK下的makecert.exe来创建用于开发的certificate.需要创建两个certificate,先创建一个self-signed root authority certificate,再创建一个用root authority certificate签名的certificate。
在Visual Studio Command Prompt下运行makecert [options] outputCertificateFile来创建
makecert的参数详见
http://msdn.microsoft.com/en-us/library/bfsktky3.aspx
/article/5140063.html
补充说明:
1.-pe 将所生成的私钥标记为可导出。可导出就是在certificate的detail label下面可以点copy to file将私钥导出,默认是不可导出的。
2.-ss store 指定证书的store name,输出证书即存储在那里。
store name对应的是MMC里面Personal,Trusted Root Certification Authorities等子路径。
具体的对应如下:
AuthRoot:third-party certificate authorities
CertificateAuthority:intermediate certificate authorities
Disallowed:Untrusted certificates(revoked certificates)
My:personal
Root:trusted root certificate authorities
TrustedPeople:trusted people
TrustedPublisher:trusted publishers
AddressBook:The X.509 certificate store for other users
3.-$ authority
指定证书的签名权限,必须设置为 commercial(对于商业软件发行者使用的证书)或 individual(对于个人软件发行者使用的证书)。
设置authority会在Certificate的detail label里面增加两个Field:Enhanced Key Usage和Key Usage Restriction.
4.-cy certType
指定证书类型。有效值是 end(对于最终实体)和 authority(对于证书颁发机构)。
-h number
指定此证书下面的树的最大高度。
分别设定Basic Constraints中的Subject Type和Path Length Constraint
其他配置有待更进一步的学习
了解了怎么使用MakeCert.exe工具就可以分别创建证书了。
先创建self signed的证书并认为它是可信的。
makecert -n "CN=RootCA" -r -sv RootCA.pvk RootCA.cer -ss Root
再用root certificate签名创建其他的证书并导入到Personal下。
makecert -iv RootCA.pvk -n "CN=MySignedCA" -ic RootCA.cer MySignedCA.cer -ss My
公钥加密也叫做非对称加密,它用一对密钥来进行加密和解密,用某用户密钥加密后所得的信息,只能用该用户的解密密钥才能解密。如果知道了其中一个,并不能计算出另外一个。因此如果公开了一对密钥中的一个,并不会危害到另外一个的秘密性质。称公开的密钥为公钥;不公开的密钥为私钥。
在用户使用公钥加密时并不能确定使用的公钥的可信性,Public Key Infrastructure就是通过引入一个可信的第三方certification authority(CA)来确保公钥的完整性和持有人的身份。
二.X.509PKI的结构
X.509 public key infrastructure标准的结构如下
-- X.509 signed certificate
---------------------------------------------------------------------
SignedContent ::= SEQUENCE
{
certificate CertificateToBeSigned,
algorithm Object Identifier,
signature BITSTRING
}
---------------------------------------------------------------------
-- X.509 certificate to be signed
---------------------------------------------------------------------
CertificateToBeSigned ::= SEQUENCE
{
version [0] CertificateVersion DEFAULT v1,
serialNumber CertificateSerialNumber,
signature AlgorithmIdentifier,
issuer Name
validity Validity,
subject Name
subjectPublicKeyInfo SubjectPublicKeyInfo,
issuerUniqueIdentifier [1] IMPLICIT UniqueIdentifier OPTIONAL,
subjectUniqueIdentifier [2] IMPLICIT UniqueIdentifier OPTIONAL,
extensions [3] Extensions OPTIONAL
}
关于数据结构的更多信息见http://msdn.microsoft.com/en-us/library/bb540790(v=vs.85).aspx
三.Store certificate
如果需要用windows service权限访问certificate,则使用local machine store.需要管理员权限存。
如果是用户权限访问,则使用current user store
在MMC snap-in里查看数字证书
1.运行mmc。
2.在File目录下点Add/Remove Snap In
3.点Add加入想要查看的Certificates。
查看和Internet Explorer有关的数字证书
在Internet Options里面选Content tab里面的Certificates
四.创建certificate
可以用Windows SDK下的makecert.exe来创建用于开发的certificate.需要创建两个certificate,先创建一个self-signed root authority certificate,再创建一个用root authority certificate签名的certificate。
在Visual Studio Command Prompt下运行makecert [options] outputCertificateFile来创建
makecert的参数详见
http://msdn.microsoft.com/en-us/library/bfsktky3.aspx
/article/5140063.html
补充说明:
1.-pe 将所生成的私钥标记为可导出。可导出就是在certificate的detail label下面可以点copy to file将私钥导出,默认是不可导出的。
2.-ss store 指定证书的store name,输出证书即存储在那里。
store name对应的是MMC里面Personal,Trusted Root Certification Authorities等子路径。
具体的对应如下:
AuthRoot:third-party certificate authorities
CertificateAuthority:intermediate certificate authorities
Disallowed:Untrusted certificates(revoked certificates)
My:personal
Root:trusted root certificate authorities
TrustedPeople:trusted people
TrustedPublisher:trusted publishers
AddressBook:The X.509 certificate store for other users
3.-$ authority
指定证书的签名权限,必须设置为 commercial(对于商业软件发行者使用的证书)或 individual(对于个人软件发行者使用的证书)。
设置authority会在Certificate的detail label里面增加两个Field:Enhanced Key Usage和Key Usage Restriction.
4.-cy certType
指定证书类型。有效值是 end(对于最终实体)和 authority(对于证书颁发机构)。
-h number
指定此证书下面的树的最大高度。
分别设定Basic Constraints中的Subject Type和Path Length Constraint
其他配置有待更进一步的学习
了解了怎么使用MakeCert.exe工具就可以分别创建证书了。
先创建self signed的证书并认为它是可信的。
makecert -n "CN=RootCA" -r -sv RootCA.pvk RootCA.cer -ss Root
再用root certificate签名创建其他的证书并导入到Personal下。
makecert -iv RootCA.pvk -n "CN=MySignedCA" -ic RootCA.cer MySignedCA.cer -ss My
相关文章推荐
- PKI(Public Key Infrastructure) 介绍
- PKI(Public Key Infrastructure)公钥基础设施
- Request for Comments: 2560 X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP
- RFC2510文档: (CMP)>Internet X.509 Public Key Infrastructure Certificate Management Protocols
- [zz]An Introduction to PKI (Public Key Infrastructure)
- PKI (Public Key Infrastructure 公共密钥基础设施)
- 继承与合成基本概念 继承:可以基于已经存在的类构造一个新类。继承已经存在的类就可以复用这些类的方法和域。在此基础上,可以添加新的方法和域,从而扩充了类的功能。 合成:在新类里创建原有的对象称为合成。
- 公钥基本结构(PKI)的概念
- 串口通信的基本概念 http://digital.ni.com/public.nsf/allkb/9F439B3D68D9072F4825703000383197
- Python 学习笔记 - 线程(基本概念和创建)
- [Win32]窗口的创建以及消息响应基本概念
- The Address Book does not contain a cross certificate capable of validating the public key
- 二叉树的基本概念、存储结构、和创建方法
- day10 反射创建数组 线程的基本概念 线程的编写和启动方式 线程的运行状态以及状态转换方法 线程的调度和优先级设置
- 用XCA(X Certificate and key management)可视化程序管理SSL 证书(3)--创建自己定义的凭证管理中心(Certificate Authority)
- mfc dll创建及基本概念