Centos CA自签证书服务器及自签证书配置手册

2023-05-16

Centos CA自签证书服务器及自签证书配置手册

  • 1 准备工作
    • 1.1 系统版本信息
    • 1.2 创建必要的目录和文件
  • 2 创建CA
    • 2.1 生成CA私钥文件(Key)
    • 2.2 生成CA自签名证书
    • 2.3 生成自签名证书(拓展部分)
    • 2.4 /etc/pki/CA/目录结构
    • 2.5 在windows中查看
  • 3 用户申请私钥
    • 3.1 用户私钥和证书申请
  • 4 CA颁发证书
    • 4.1 查看颁发证书信息
    • 4.2 将根证书导入受信任的组织
    • 4.3 查看www证书
  • 5 结束

1 准备工作

1.1 系统版本信息

[08:33:10 root@centos8 ~]#cat /etc/redhat-release
CentOS Linux release 8.4.2105
[08:33:26 root@centos8 ~]#openssl version
OpenSSL 1.1.1g FIPS  21 Apr 2020

1.2 创建必要的目录和文件

mkdir -pv /etc/pki/CA/{certs,crl,newcerts,private}
touch /etc/pki/CA/index.txt
echo 01 > /etc/pki/CA/serial
mkdir /data/app1 -p
[08:28:54 root@centos8 ~]#mkdir -pv /etc/pki/CA/{certs,crl,newcerts,private}
mkdir: created directory '/etc/pki/CA'
mkdir: created directory '/etc/pki/CA/certs'
mkdir: created directory '/etc/pki/CA/crl'
mkdir: created directory '/etc/pki/CA/newcerts'
mkdir: created directory '/etc/pki/CA/private'
[08:28:58 root@centos8 ~]#touch /etc/pki/CA/index.txt
[08:29:16 root@centos8 ~]#echo 01 > /etc/pki/CA/serial
[08:29:23 root@centos8 ~]#mkdir /data/app1 -p

2 创建CA

2.1 生成CA私钥文件(Key)

( umask 066;openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048 )
[08:30:27 root@centos8 ~]#( umask 066;openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048 )
Generating RSA private key, 2048 bit long modulus (2 primes)
.........................................+++++
...................................+++++
e is 65537 (0x010001)

在这里插入图片描述

2.2 生成CA自签名证书

openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -days 3650 -out /etc/pki/CA/cacert.pem
[08:35:22 root@centos8 ~]#openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -days3650 -out /etc/pki/CA/cacert.pem
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]:CN
State or Province Name (full name) []:Shanghai
Locality Name (eg, city) [Default City]:Shanghai
Organization Name (eg, company) [Default Company Ltd]:Panasonic Information System CO.,LTD.
Organizational Unit Name (eg, section) []:IT Dept
Common Name (eg, your name or your server's hostname) []:ca.pana.local
Email Address []:

在这里插入图片描述

可以看到这部分信息和我们之前输入的相同.
在这里插入图片描述

2.3 生成自签名证书(拓展部分)

那么如果是批量生成的话应该怎么处理?
可以使用-subj 将这部分信息传入,当然也可以用expect这类的工具.

openssl req -new -x509 -subj "/C=CN/ST=Shanghai/L=Shanghai/O='Panasonic Information System CO.,LTD.'/OU='IT Dept'/CN=ca2.pana.local" -key /etc/pki/CA/private/cakey.pem -days 3650 -out /data/app1/cacert.pem
[08:47:50 root@centos8 ~]#openssl req -new -x509 -subj "/C=CN/ST=Shanghai/L=Shanghai\
/O='Panasonic Information System CO.,LTD.'/OU='IT Dept'/CN=ca2.pana.local"\
 -key /etc/pki/CA/private/cakey.pem -days 3650 -out /data/app1/cacert.pem

看到这部分信息一样生成
在这里插入图片描述

2.4 /etc/pki/CA/目录结构

[09:16:10 root@centos8 ~]#tree /etc/pki/CA/
/etc/pki/CA/
├── cacert.pem
├── certs
├── crl
├── index.txt
├── newcerts
├── private
│   └── cakey.pem
└── serial

2.5 在windows中查看

将证书下载到windows上,并改名成crt
此时我们可以看到证书是不受信任的.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3 用户申请私钥

3.1 用户私钥和证书申请

这里我们用脚本直接完成这2部分的申请,申请完只需要将crt文件发送给CA.

cat >> ssl.sh<<EOF
#!/bin/bash
Ssl_dir=/data/ssl
Url=www.pana.local
Keyfile=$Ssl_dir/$Url.key
Crtfile=$Ssl_dir/$Url.csr
[ -d $Ssl_dir ] || mkdir $Ssl_dir -p
[ `rpm -qa|grep openssl|wc -l` -gt 0 ] || yum install openssl -y

( umask 066;openssl genrsa -out $Keyfile 2048 )
openssl req -new -subj "/C=CN/ST=Shanghai/L=Shanghai/O=Panasonic Information System CO.,LTD./OU='IT Dept'/CN=$Url" -key $Keyfile -out $Crtfile
EOF
bash ssl.sh

在这里插入图片描述

4 CA颁发证书

openssl ca -in /data/ssl/www.pana.local.csr -out /data/ssl/www.pana.local.crt
[09:20:45 root@centos8 ~]#openssl ca -in /data/ssl/www.pana.local.csr -out /data/ssl/www.pana.local.crt
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: Aug 11 01:20:50 2021 GMT
            Not After : Aug 11 01:20:50 2022 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = Shanghai
            organizationName          = Panasonic Information System CO.,LTD.
            organizationalUnitName    = 'IT Dept'
            commonName                = www.pana.local
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Comment:
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
                19:54:3F:8B:FE:0A:FA:EE:81:1B:BF:9A:99:59:B0:6B:AE:E3:A1:15
            X509v3 Authority Key Identifier:
                keyid:B2:2D:5E:BC:90:71:DB:28:9B:59:22:F8:63:7F:05:A3:B3:57:F3:67

Certificate is to be certified until Aug 11 01:20:50 2022 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

在这里插入图片描述

4.1 查看颁发证书信息

在这里插入图片描述

4.2 将根证书导入受信任的组织

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.3 查看www证书

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5 结束

到此证书颁发已经完成,可以将证书绑定到需要的软件上即可.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Centos CA自签证书服务器及自签证书配置手册 的相关文章

随机推荐

  • python 字符串里面提取变量的方法

    1 字符串拼接 比如单引号和2个 43 号里面的就是变量 2 占位符 S 有多个变量在后面逗号分隔即可
  • 树莓派Raspbian更新源(Debian)| 完整解决步骤

    转载自 xff1a 树莓派更新源更换 树莓派小无相系列 型号 xff1a 树莓派 3b 43 系统 xff1a Raspbian系统 xff08 Debian xff09 本质 xff1a 常见更新教程是更新 xff1a etc apt s
  • 【ABAQUS】hypermesh如何导出CEL网格到Abaqus

    Abaqus的CEL具备流固耦合分析能力 xff0c 有些朋友喜欢用hm进行网格划分 xff0c 但hm划分的欧拉体是无法直接导入到AbaqusCAE界面的 xff0c 本文提供导入方法如下 xff0c 希望对遇到问题的朋友有所帮助 第1步
  • 编译原理和技术 Lab 1 Lexical Analysis

    Lab 1 Lexical Analysis 1 Goal You are given A public repository of a incomplete project on Gitlab The URL is http 210 45
  • mybatis 的xml文件中调用java的方法

    1 使用场景 最近在做项目开发时 xff0c 遇到一个很棘手的问题 xff0c 前端传的搜索条件 xff0c 不能简单的作为查询条件 xff0c 直接传给后端 xff0c 而需要处理之后才可以作为条件 xff0c 拼接到sql中去 2 解决
  • 好用的工具分享

    1 比较好用的远程控制软件parsec Connect to Work or Games from Anywhere Parsec https parsec app 2 比较好用的JSON内容对比工具 JSON Compare Best J
  • mysql 将数据库表字段全部转为小写

    需求场景 xff1a 最近在开发项目时 xff0c 需要创建一张表 xff0c 发现别的库 xff0c 已经有人创建了 xff0c 于是便把建表语言拿过来 xff0c 直接建表 xff0c 但是有一件不爽的事 xff0c 原来创建表时 xf
  • python中 文件明明存在,但是os.path.exists 返回False

    文件明明存在 xff0c 但是用os path exists xff08 xff09 返回False xff0c 通过试验发现 xff0c 路径或者文件名中还有中文就会返回fasle xff0c 所以文件夹的名称或者文件名最好不要含有中文
  • redhat7.4安装ansible

    ansible是什么就不做介绍了 xff0c 网上一大堆 xff0c 在线安装也比较简单 xff0c 因为特别原因 xff0c 我们的服务器全部在内网运行 xff0c 所以必须采用离线安装 1 ansible安装方式有 源码 pip yum
  • Android硬件通信之 串口通信

    一 xff0c 串口介绍 1 1 串口简介 串行接口简称串口 xff0c 也称串行通信接口或串行通讯接口 xff08 通常指COM接口 xff09 xff0c 是采用串行通信方式的扩展接口 xff1b 串行接口 xff08 SerialIn
  • 【环境配置 skills】sublime 配置 MinGW 搭建 C/C++ 编程环境

    sublime 配置 MinGW 搭建 C C 43 43 编程环境 当安装好 MinGW 和 sublime text 后 xff0c 执行下面2个动作 xff1a 按照菜单 Tools 61 61 gt Build System 61
  • 【Java】npm 国内下载慢的问题解决

    打开 cmd 命令窗口使用淘宝 npm 镜像定制的 cnpm gzip 压缩支持 命令行工具代替默认的 npm xff1b 安装 cnpm 命令 xff1a npm install g cnpm registry 61 https regi
  • Python3之3天极速入门五迭代器与生成器

    34 34 34 Python3 迭代器与生成器 迭代是Python最强大的功能之一 xff0c 是访问集合元素的一种方式 迭代器是一个可以记住遍历的位置的对象 迭代器对象从集合的第一个元素开始访问 xff0c 直到所有的元素被访问完结束
  • 记一篇在sata固态上安装好系统的电脑上加装m2固态硬盘,是如何重装系统的

    倒腾了块三星的m2接口固态硬盘 xff0c 但是死活装不上系统 问了好多人终于解决了 xff0c 现在总结一下 xff0c 万一有人用得着 m2固态装好之后正常启动 我用的是大白菜制作工具 xff0c 按普通的做系统盘的方式做好一个启动盘
  • 睿客云盘更新日志

    睿客云盘PC版本 V3 0 7 睿客云盘PC版 更新内容 xff1a 1 修复登录客户端提示网络异常问题 2 修复视频文件右键打开播放失败问题 3 修复分享 64 我功能部分异常问题 4 新增支持睿客网账号登录 5 优化视频播放窗口 202
  • HDFS中web端查看/tmp目录与/user目录时权限不足的问题解决

    在查看browse directory时 xff0c 点击 tmp 或 user xff0c 无法进入 xff0c 报错 xff1a Permission denied user 61 dr who access 61 READ EXECU
  • 【WSL】WSL迁移教程

    写在前面 如果我们是通过Windows Store进行安装的 xff0c 就会默认安装到C盘 在使用过程中 xff0c WSL占用空间会越来越大 xff0c 很容易让C盘爆满 xff0c 所以我们需要将其迁移到其他非C盘的地方 终止正在运行
  • 【WSA】Win11 安卓子系统配置上网方法

    搜索系统环境变量 xff1a 在里面添加ADB的安装路径 xff1a 在终端里输入adb version xff0c 测试adb是否正常工作 xff1a 在终端里输入ipconfig xff0c 查看安卓子系统IP地址 xff1a 在终端输
  • 【WSA】Win11安卓子系统提示VirtWifi的连接受限的解决方法

    问题描述 每次WSA启动时都会有如下提示 xff1a 虽说不影响使用 xff0c 但是看着实在是闹心 解决方案 1 下载ADB工具 xff1a Platform tools下载 Platform tools 安卓调试工具包 官方版下载 系统
  • Centos CA自签证书服务器及自签证书配置手册

    Centos CA自签证书服务器及自签证书配置手册 1 准备工作1 1 系统版本信息1 2 创建必要的目录和文件 2 创建CA2 1 生成CA私钥文件 Key 2 2 生成CA自签名证书2 3 生成自签名证书 拓展部分 2 4 etc pk