前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Easy-RSA自签发证书(服务端和客户端共用CA证书)

Easy-RSA自签发证书(服务端和客户端共用CA证书)

作者头像
张哥编程
发布2024-12-07 16:43:18
发布2024-12-07 16:43:18
43900
代码可运行
举报
文章被收录于专栏:云计算linux云计算linux
运行总次数:0
代码可运行

场景描述 Easy-RSA是一个开源的证书管理工具,用于帮助用户生成和管理数字证书。

本示例介绍在Windows操作系统中,通过Easy-RSA自签发证书,服务端和客户端共用CA证书。本示例使用的软件版本为Easy-RSA 3.1.7,不同软件版本之间可能存在差异,具体请参考官方指导说明。

操作步骤 根据Windows操作系统下载Easy-RSA安装包至“D:\”目录下。 Windows 32位操作系统,可以下载EasyRSA-3.1.7-win32.zip。 Windows 64位操作系统,可以下载EasyRSA-3.1.7-win64.zip。 此处以安装EasyRSA-3.1.7-win64为示例。

点击放大

解压缩“EasyRSA-3.1.7-win64.zip”至指定目录,如“D:\EasyRSA-3.1.7”。 进入“D:\EasyRSA-3.1.7”目录。 在地址栏中输入cmd并按回车键,打开命令行窗口。 执行“.\EasyRSA-Start.bat”命令,运行Easy-RSA。 系统显示如下类似信息:

Welcome to the EasyRSA 3 Shell for Windows. Easy-RSA 3 is available under a GNU GPLv2 license.

Invoke './easyrsa' to call the program. Without commands, help is displayed.

EasyRSA Shell

代码语言:javascript
代码运行次数:0
运行
复制
执行“./easyrsa init-pki”命令,初始化PKI环境。

系统显示如下类似信息: Notice

'init-pki' complete; you may now create a CA or requests.

Your newly created PKI dir is:

  • D:/EasyRSA-3.1.7/pki

Using Easy-RSA configuration:

  • undefined

EasyRSA Shell

执行命令后,在“D:\EasyRSA-3.1.7”的目录下自动生成了“pki”的文件夹。

配置变量参数。 将“D:\EasyRSA-3.1.7”目录下的“vars.example”文件复制到“D:\EasyRSA-3.1.7\pki”目录下。 将“D:\EasyRSA-3.1.7\pki”目录下的“vars.example”重命名为“vars”。 说明: 默认按“vars.example”中描述的参数值进行配置。如需自定义参数值,按需设置“vars”文件的参数值。

代码语言:javascript
代码运行次数:0
运行
复制
执行“ ./easyrsa build-ca nopass”命令,生成CA证书。

系统显示如下类似信息:

Using Easy-RSA 'vars' configuration:

  • D:/EasyRSA-3.1.7/pki/vars

Using SSL:

  • openssl OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023) .....+..+.............+......+........+...+...+....+++++++++++++++++++++++++++++++++++++++.+.+.....+..........+............+...+++++++++++++++++++++++++++++++++++++++............+.....+......+...+....+..+..........+.....+....+...............+..+.........+.............+......+..+...+....+..+.+.........+.....+.........+....+............+...+...+.....+........................+...+.+.....+....+...+.........+...+...+...+.....+......+........................++++++ .+++++++++++++++++++++++++++++++++++++++.........+..........+++++++++++++++++++++++++++++++++++++++.+......++++++

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.

Common Name (eg: your user, host, or server name) [Easy-RSA CA]:p2cvpn.com //设置CA证书名称

Notice

CA creation complete. Your new CA certificate is at:

  • D:/EasyRSA-3.1.7/pki/ca.crt

EasyRSA Shell

查看CA证书及其私钥。 生成的CA证书默认存放在“D:\EasyRSA-3.1.7\pki”目录下。 本示例中生成的证书为“ca.crt”。

生成的CA私钥默认存放在“D:\EasyRSA-3.1.7\pki\private”目录下。 本示例中生成的私钥为“ca.key”。

代码语言:javascript
代码运行次数:0
运行
复制
执行 “./easyrsa build-server-full p2cserver.com nopass”命令,生成服务端证书及其私钥。

此命令中,“p2cserver.com”为服务端证书的CN,必须是域名格式,如“p2c-server.com”。否则无法正常托管到云证书管理服务,请根据实际填写。

系统显示如下类似信息:

Using Easy-RSA 'vars' configuration:

  • D:/EasyRSA-3.1.7/pki/vars

Using SSL:

  • openssl OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023) .+............+........+............+............+.+...............+.....+....+....................+............+.+..+......+............+....+.........+..+.........+.+.........+..............+.........+++++++++++++++++++++++++++++++++++++++...+......+.....+......+...+++++++++++++++++++++++++++++++++++++++..+...+..........+......+...........+....+......+.....+....+.....+....+........+...+.......+...+..+.......+..+......+.............+..+....+......+...+.....+................+......+..+.............+..+................+.....+......+....+...........+....+.....+.........+.+..+.............+...........+..........+......+........+............+...+....+..+......+......................+.....+......+.+...+..+...+.+......+........+...+....+.....+......+....+...+..+................+..+...+.......+..+......+..........+.........+...+..+.........+......+......++++++ ........+.+......+...+......+.....+...+.+.....+.+........+......+++++++++++++++++++++++++++++++++++++++...+.....+...+.+.........+......+........+++++++++++++++++++++++++++++++++++++++......+........+.+...+.....+.+..............+.+.....+.+...+...+.....+.......+.................+.+............+..+......+...+....+...+..+.+.....+.....................+.+..+.+...................................+....+........+.............+.....+....+.....+...+..........+........+.+.....+...+.............+........+....+......+.....+.......+..+............+.........+.+......+...+...............+......+...........+............+.......+...........+.......+...............+......+.................+...+.+...+..+...+.+..........................+.+.........+......+............+..+....+..+....+........+.......+........+...+...+.+...+...+..+...............+...+..........+..+.......+.........+.....+.........+................+......+...+......+.....+.......+...+..............+.+.....+.+...+...........+.+...+...+...+............+..+.......+...........+.......+...+...+...........+.....................+...+....+...........+............+...+......+..........+........+.+.....+....+.....+.+..+..........+..............+...+......+.+...+...........+.+......+...++++++

Notice

Private-Key and Public-Certificate-Request files created. Your files are:

  • req: D:/EasyRSA-3.1.7/pki/reqs/p2cserver.com.req
  • key: D:/EasyRSA-3.1.7/pki/private/p2cserver.com.key

You are about to sign the following certificate: Request subject, to be signed as a server certificate for '825' days:

subject= commonName = p2cserver.com

Type the word 'yes' to continue, or any other input to abort. Confirm request details: yes //输入“yes”以继续

Using configuration from D:/EasyRSA-3.1.7/pki/openssl-easyrsa.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'p2cserver.com' Certificate is to be certified until Sep 22 09:56:54 2026 GMT (825 days)

Write out database with 1 new entries Database updated

Notice

Certificate created at:

  • D:/EasyRSA-3.1.7/pki/issued/p2cserver.com.crt

Notice

Inline file created:

  • D:/EasyRSA-3.1.7/pki/inline/p2cserver.com.inline

EasyRSA Shell

查看服务端证书及其私钥。 生成的服务端证书默认存放在“D:\EasyRSA-3.1.7\pki\issued”目录下。 本示例中生成的服务端证书为“p2cserver.com.crt”。

生成的服务端私钥默认存放在“D:\EasyRSA-3.1.7\pki\private”目录下。 本示例中生成的服务端私钥为“p2cserver.com.key”。

执行“ ./easyrsa build-client-full p2cclient.com nopass”命令,生成客户端证书及其私钥。 此命令中,客户端证书的命名(如“p2cclient.com”)应与服务端证书的命名(如“p2cserver.com”)不一致。

系统显示如下类似信息:

Using Easy-RSA 'vars' configuration:

  • D:/EasyRSA-3.1.7/pki/vars

Using SSL:

  • openssl OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023) .......+++++++++++++++++++++++++++++++++++++++...+...+...+.....+...+....+......+......+........+.+.....+............+++++++++++++++++++++++++++++++++++++++.+.....+.+.....+.........+.......+..+...+.......+...+..+......+.+......+........+....+...+...+..+.......+......+.....+..........+...........+....+......+.....+.........+......+.+..+...+..........+........+......+....+......+...........+.......+.....+.............+..+.+...........+..........+...+..+.........+......+.+........+.........+.+...............+..+..........+...+............+...+.....+.+...........+....+.....+.........+....+.......................+....+...+..+....+..+.......+...+............+.....+............+.+........+.......+.....+....+.........+..+............+..........+..+.............+...+...+..++++++ ..+.....+.......+.....+.........+....+++++++++++++++++++++++++++++++++++++++.....+......+..+++++++++++++++++++++++++++++++++++++++.......+.+.....+....+.........+...+.....+.........+...+...............+...+....+.....+.+...+......+......+...+.........+..+...+...+....+.........+..+...+...................+......+.....+.+...+...+.........+.....+..................+...+...+......+.+..+......+.+......+.....+...+..........+..+............+.......+.........+.....+......+.+..+............+................+..+...+....+......+.....+...+....+..+......+.........+.........++++++

Notice

Private-Key and Public-Certificate-Request files created. Your files are:

  • req: D:/EasyRSA-3.1.7/pki/reqs/p2cclient.com.req
  • key: D:/EasyRSA-3.1.7/pki/private/p2cclient.com.key

You are about to sign the following certificate: Request subject, to be signed as a client certificate for '825' days:

subject= commonName = p2cclient.com

Type the word 'yes' to continue, or any other input to abort. Confirm request details: yes //输入“yes”以继续

Using configuration from D:/EasyRSA-3.1.7/pki/openssl-easyrsa.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows commonName :ASN.1 12:'p2cclient.com' Certificate is to be certified until Sep 22 09:58:26 2026 GMT (825 days)

Write out database with 1 new entries Database updated

Notice

Certificate created at:

  • D:/EasyRSA-3.1.7/pki/issued/p2cclient.com.crt

Notice

Inline file created:

  • D:/EasyRSA-3.1.7/pki/inline/p2cclient.com.inline

EasyRSA Shell

查看客户端证书及其私钥。 生成的客户端证书默认存放在“D:\EasyRSA-3.1.7\pki\issued”目录下。 本示例中生成的客户端证书为“p2cclient.com.crt”。

生成的客户端私钥默认存放在“D:\EasyRSA-3.1.7\pki\private”目录下。 本示例中生成的客户端私钥为“p2cclient.com.key”。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-11-05,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 系统显示如下类似信息: Notice
  • 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.
  • Notice
  • Notice
  • Notice
  • Notice
  • Notice
  • Notice
  • Notice
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档