gpg非对称和简单的CA创建、签署、吊销

gpg实现非对称加密 

创建初始文件

 使用gpg生成密钥

 输入自定义密码

 弱口令提示

生成需要对磁盘进行操作,我使用了dd

 查看公钥,并导出,发送到另一个主机

 到28导入并查看

 加密并传回

 也可以在7远程拷贝

 图上的信息证明是刚从28拉过来的

 

解密文件 

 

 可以直接解锁查看,此时不生成新文件,也可使用自定义或者-o选项生成新文件

 

使用openssl实现简单的根CA创建自签名证书及常用操作

先看一下配置文件

vim /etc/pki/tls/openssl.cnf
#在这个文件中规定了一些规则,如果违背就无法成功创建或者签名
#对根CA的私钥和证书等信息有具体的命名要求

[ ca ] default_ca
= CA_default # The default ca section #################################################################### [ CA_default ] dir = /etc/pki/CA # Where everything is kept certs = $dir/certs # Where the issued certs are kept crl_dir = $dir/crl # Where the issued crl are kept database = $dir/index.txt # database index file. #unique_subject = no # Set to 'no' to allow creation of # several ctificates with same subject. new_certs_dir = $dir/newcerts # default place for new certs. certificate = $dir/cacert.pem # The CA certificate serial = $dir/serial # The current serial number crlnumber = $dir/crlnumber # the current crl number # must be commented out to leave a V1 CRL crl = $dir/crl.pem # The current CRL private_key = $dir/private/cakey.pem # The private key RANDFILE = $dir/private/.rand # private random number file x509_extensions = usr_cert # The extentions to add to the cert # Comment out the following two lines for the "traditional" # (and highly broken) format. name_opt = ca_default # Subject Name options cert_opt = ca_default # Certificate field options

 

准备环境

 

 创建私钥 

固定的格式,在/etc/pki/tls/openssl.cnf中有相关设置

 

 自签名及查看

 

 为了颁发证书需要创建两个文件

touch index.txt    #证书索引数据库文件 
echo 01 > serial     #指定第一个颁发证书的序列号,使用的是16进制

 

 

 

# old和attr后缀如果没有颁发过证书就没有

创建私钥并生成证书申请文件

 

 #规则文件中有对其的要求,默认要求国家,省份和组织必须相同

CA签名颁发

 

 

 

 

 查看证书状态

 

 吊销

 

 #此时还未完全吊销,还需要更新列表

 #初次吊销时要执行命令

 echo 01 > /etc/pki/CA/crlnumber

 

#然后更新证书吊销列表

 

posted @ 2020-09-05 20:39  天际之上可有蓝天  阅读(404)  评论(0编辑  收藏  举报