OpenVPN easy-rsa 配置
easy-rsa 是创建和管理PKI CA的命令行工具,封装了openssl命令,降低CA建立和管理门槛。最开始随openvpn一起发行,后来[]独立发行](https://github.com/OpenVPN/easy-rsa)。下文使用版本为Easy-RSA 3。
easy-rsa安装与初始化
- easy-rsa 安装
$ apt-get install easy-rsa #yum install easy-rsa - 创建或者重新初始化PKI
$ cd /usr/share/easy-rsa/ $ ./easyrsa init-pki $ ls -l pki #查看目录结构 total 8 drwx------ 2 root root 4096 Feb 15 02:53 private #私钥存储目录 drwx------ 2 root root 4096 Feb 15 02:53 reqs #证书认证申请目录 - 创建CA
$ cd /usr/share/easy-rsa/ $ ./easyrsa build-ca $ ls -al pki total 32 drwx------ 6 root root 4096 Feb 15 03:28 . drwx------ 7 root root 4096 Feb 15 02:53 .. -rw------- 1 root root 1224 Feb 15 03:28 ca.crt #CA证书 drwx------ 2 root root 4096 Feb 15 03:28 certs_by_serial -rw------- 1 root root 0 Feb 15 03:28 index.txt # drwx------ 2 root root 4096 Feb 15 03:28 issued #已经签发证书 drwx------ 2 root root 4096 Feb 15 03:28 private drwx------ 2 root root 4096 Feb 15 02:53 reqs -rw------- 1 root root 3 Feb 15 03:28 serial
easy-rsa生产密钥对和待认证的证书(PKCS#10)
$ cd /usr/share/easy-rsa/
$ ./easyrsa gen-req server1 nopass #nopass不设置密码,不加密私钥
$ ./easyrsa gen-req client1 nopass #nopass不设置密码,不加密私钥
$ ./easyrsa gen-crl
easy-rsa签发证书
$ cd /usr/share/easy-rsa/
$ ./easyrsa sign-req server server1 #服务器证书
$ ./easyrsa sign-req client client1 #个人证书
撤销证书
$ cd /usr/share/easy-rsa/
$ ./easyrsa revoke server1
$ ./easyrsa revoke client1
生成Diffie-Hellman文件(在TLS服务中使用)
$ cd /usr/share/easy-rsa/
$ ./easyrsa gen-dh