Linux CA

Stella981
• 阅读 877

CA(Certificate Authority)证书颁发机构主要负责证书的颁发、管理以及归档和吊销。证书内包含了拥有证书者的姓名、地址、电子邮件帐号、公钥、证书有效期、发放证书的CA、CA的数字签名等信息。证书主要有三大功能:加密、签名、身份验证。

1.什么是CA认证?

CA认证,即CA认证机构,为电子签名相关各方提供真实性、可靠性验证的行为。

2.什么是CA证书?

证书实际是由证书签证机关(CA)签发的对用户的公钥的认证。

3.CA证书类型?

  • 证书颁发机构自签名证书
  • 服务器证书
  • 用户证书

二. CA服务器部署

1. 部署环境

[root@linux-ca ~]# touch /etc/pki/CA/index.txt  #index.txt:索引文件,用于匹配证书编号;
[root@linux-ca ~]# echo 01 >/etc/pki/CA/serial  #serial:证书序列号文件,只在首次生成证书时赋值。
[root@linux-ca ~]# cat /etc/pki/CA/serial 
01

2. 生成密钥

[root@linux-ca private]# (umask 077; openssl genrsa -out /etc/pki/CA/private/cakay.pem 2048)

     genrsa:生成私钥;

     -out:私钥的存放路径,cakey.pem:为密钥名,与配置文件中保持一致;

     2048:密钥长度,默认为1024。

3. 修改配置文件/etc/pki/tls/openssl.cnf

40 [ CA_default ]
 41 
 42 dir             = /etc/pki/CA           # Where everything is kept
 43 certs           = $dir/certs            # Where the issued certs are kept
 44 crl_dir         = $dir/crl              # Where the issued crl are kept
 45 database        = $dir/index.txt        # database index file.
 46 #unique_subject = no                    # Set to 'no' to allow creation of
 47                                         # several ctificates with same subject.
 48 new_certs_dir   = $dir/newcerts         # default place for new certs.
 49 
 50 certificate     = $dir/cacert.pem       # The CA certificate
 51 serial          = $dir/serial           # The current serial number
 52 crlnumber       = $dir/crlnumber        # the current crl number
 53                                         # must be commented out to leave a V1 CRL
 54 crl             = $dir/crl.pem          # The current CRL
 55 private_key     = $dir/private/cakey.pem# The private key
 56 RANDFILE        = $dir/private/.rand    # private random number file
 
 83 # For the CA policy
 84 [ policy_match ]
 85 countryName             = match
 86 stateOrProvinceName     = match
 87 organizationName        = match
 88 organizationalUnitName  = optional
 89 commonName              = supplied
 90 emailAddress            = optional

128 [ req_distinguished_name ]
129 countryName                     = Country Name (2 letter code)
130 countryName_default             = US
131 countryName_min                 = 2
132 countryName_max                 = 2
133 
134 stateOrProvinceName             = State or Province Name (full name)
135 stateOrProvinceName_default     = California
136 
137 localityName                    = Locality Name (eg, city)
138 localityName_default            = Redwood City
139 
140 0.organizationName              = Organization Name (eg, company)
141 0.organizationName_default      = Electronic Arts, Inc.
142 
143 # we can do this but it is not needed normally :-)
144 #1.organizationName             = Second Organization Name (eg, company)
145 #1.organizationName_default     = World Wide Web Pty Ltd
146 
147 organizationalUnitName          = Organizational Unit Name (eg, section)
148 organizationalUnitName_default  = EA Online/pogo.com
149 
150 commonName                      = Common Name (eg, your name or your server\'s hostname)
151 commonName_max                  = 64
152 commonName_default              =
153 
154 emailAddress                    = Email Address
155 emailAddress_max                = 64
156 emailAddress_default            =

4. CA 创建自签根证书

[root@linux-ca CA]# openssl req -new -x509 -key /etc/pki/CA/private/cakay.pem -out /etc/pki/CA/cacert.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
State or Province Name (full name) [California]:
Locality Name (eg, city) [Redwood City]:
Organization Name (eg, company) [Electronic Arts, Inc.]:
Organizational Unit Name (eg, section) [EA Online/pogo.com]:
Common Name (eg, your name or your server's hostname) []:cacert
Email Address []:vxxxxxxxxxxxxxxxxx

   req:生成证书签署请求;

   -x509:生成自签署证书;

   -days n:证书的有效天数;

   -new:新请求;

   -key /path/to/keyfile:指定私钥文件;

   -out /path/to/somefile:输出文件位置。

三. 客户端申请证书

1. 生成客户端私钥

[root@web ~]# mkdir ssl
[root@web ~]# cd ssl/
[root@web ssl]# (umask 077; openssl genrsa -out /root/ssl/web.key 2048)
Generating RSA private key, 2048 bit long modulus
.......................................+++
.................................................+++
e is 65537 (0x10001)

2. 生成证书请求文件

[root@web ssl]# openssl req -new -key /root/ssl/web.key -out /root/ssl/web.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:US
State or Province Name (full name) []:California
Locality Name (eg, city) [Default City]:Redwood City
Organization Name (eg, company) [Default Company Ltd]:Electronic Arts, Inc.
Organizational Unit Name (eg, section) []:EA Online/pogo.com
Common Name (eg, your name or your server's hostname) []:web
Email Address []:xxxxxxxxxxx

3. 将生成的申请文件发送到CA颁发服务器

[root@web ssl]# scp web.csr root@10.17.160.241:/etc/pki/CA/csr/

四. CA服务器为客户端颁发证书

1.为客户端颁发证书

[root@linux-ca CA]# openssl ca -in /etc/pki/CA/csr/web.csr -out /etc/pki/CA/certs/web.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: May 15 06:58:48 2019 GMT
            Not After : May 14 06:58:48 2020 GMT
        Subject:
            countryName               = US
            stateOrProvinceName       = California
            organizationName          = Electronic Arts, Inc.
            organizationalUnitName    = EA Online/pogo.com
            commonName                = web
            emailAddress              = vli@contractor.ea.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                4E:FE:C1:E2:17:92:C6:D1:48:42:70:1F:59:95:FA:9D:49:76:B0:47
            X509v3 Authority Key Identifier: 
                keyid:82:81:30:91:40:F8:D2:FD:B4:D5:A8:52:DF:FE:D2:62:12:38:53:7F

Certificate is to be certified until May 14 06:58:48 2020 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

2. 将生成的证书发送给申请的客户端

五. 吊销证书

1. 获取证书serial

[root@linux-ca CA]# openssl x509 -in certs/web.crt -noout -serial -subject
serial=01
subject= /C=US/ST=California/O=Electronic Arts, Inc./OU=EA Online/pogo.com/CN=web/emailAddress=xxxxxxxxxxxxxx

   x509:证书格式;

   -in:要吊销的证书;

   -noout:不输出额外信息;

   -serial:显示序列号;

   -subject:显示subject信息。

二) CA验证信息

1、节点提交的serial和subject信息来验证与index.txt文件中的信息是否一致
Linux CA
2、吊销证书
Linux CA
-revoke:删除证书。

查看被吊销的证书列表
Linux CA
3、生成吊销证书的编号(如果是第一次吊销)
Linux CA
4、更新证书吊销列表
Linux CA
-gencrl:生成证书吊销列表;
5、查看crl文件内容
Linux CA

-text:以文本形式显示。

参考: https://www.linuxprobe.com/private-ca.html

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
java访问Https服务的客户端示例
关于证书1、每个人都可以使用一些证书生成工具为自己的https站点生成证书(比如JDK的keytool),大家称它为“自签名证书”,但是自己生成的证书是不被浏览器承认的,所以浏览器会报安全提示,要求你手动安装证书,提示风险,是否继续等。只有通过权威的CA机构付费获得的证书才能被浏览器承认。2、证书(无客户端服务端之分)保存着IP信息、证书过
高防加速CDN 高防加速CDN
1年前
为什么安装了SSL证书,网站还是显示不安全?
SSL证书是数字证书的一种,类似于驾驶证、护照和营业执照的电子副本。因为配置在服务器上,也称为SSL服务器证书。SSL证书就是遵守SSL协议,由受信任的数字证书颁发机构CA,在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。由于http明文方式
Stella981 Stella981
3年前
Fabric CA证书管理教程
FabricCA是HyperledgerFabric自带的证书管理工具,对于开发和测试非常方便。在这个教程中我们将探索FabricCA的使用方法并利用它完成用户的注册/Register和登记/Enrollment。HyperledgerFabric是一个许可制的区块链平台,在访问Fabric网络之前必须先进行身份识别并获得访问许可。Fabric网
Stella981 Stella981
3年前
OpenSSL创建生成CA证书、服务器、客户端证书及密钥
使用OpenSSL创建生成CA证书、服务器、客户端证书及密钥目录使用OpenSSL创建生成CA证书、服务器、客户端证书及密钥(一)生成CA证书(二)生成服务器证书(三)生成客户端证书说明:
Stella981 Stella981
3年前
Apache httpd服务
!(https://oscimg.oschina.net/oscnet/fe6d1798e33674a302b8ff67a7312ca2a67.png)https的实现​1)CA服务器端,生成自签证书root@ca~cd/etc/pki/CA/root@caCA(umask077;
Wesley13 Wesley13
3年前
HTTPS安全通信过程
一、两对公私钥1、CA公私钥:CA公钥:预装在操作系统,内置在浏览器中。备注:微软等公司会根据一些权威安全机构的评估选取一些信誉很好并且通过一定的安全认证的证书发布机构,把这些证书发布机构的证书默认安装在操作系统中,并且设置为操作系统信任的数字证书。CA私钥:由CA机构保管,不会外泄。2、服务公私钥:服
Wesley13 Wesley13
3年前
oracle游标的例子
declare    cursor ca is select id_no, name from user where ym201401;begin    for cb in ca loop        update path set enamecb.name where id_nocb.id
Stella981 Stella981
3年前
Kubernetes集群部署之二CA证书制作
创建TLS证书和秘钥kubernetes系统的各组件需要使用TLS证书对通信进行加密,本文档使用CloudFlare的PKI工具集cfssl来生成CertificateAuthority(CA)和其它证书.1\.下载并安装CFSSL:root@k8smaster~cd/usr/local/src
Stella981 Stella981
3年前
Chrome 或将于2018年正式弃用 HPKP 公钥固定标准
早些年谷歌工程师为了提高互联网整体的安全性避免因证书颁发机构违规操作而设计了HPKP公钥固定标准。公钥固定允许网站在服务器部署证书颁发机构的哈希值,若网站使用的证书与固定的哈希不对应则拒绝连接。公钥固定的现实意义在于如果有CA证书颁发机构违规向某个域名私自签发证书那么也无法实现对网站的劫持。但是现在谷歌浏览器已经决定弃用HPKP公钥固定标准