165 |
- |
1 |
EASY-RSA Version 2.0-rc1
|
|
|
2 |
|
|
|
3 |
This is a small RSA key management package, based on the openssl
|
|
|
4 |
command line tool, that can be found in the easy-rsa subdirectory
|
|
|
5 |
of the OpenVPN distribution. While this tool is primary concerned
|
|
|
6 |
with key management for the SSL VPN application space, it can also
|
|
|
7 |
be used for building web certificates.
|
|
|
8 |
|
|
|
9 |
These are reference notes. For step-by-step instructions, see the
|
|
|
10 |
HOWTO:
|
|
|
11 |
|
|
|
12 |
http://openvpn.net/howto.html
|
|
|
13 |
|
|
|
14 |
This package is based on the ./pkitool script. Run ./pkitool
|
|
|
15 |
without arguments for a detailed help message (which is also pasted
|
|
|
16 |
below).
|
|
|
17 |
|
|
|
18 |
Release Notes for easy-rsa-2.0
|
|
|
19 |
|
|
|
20 |
* Most functionality has been consolidated into the pkitool
|
|
|
21 |
script. For compatibility, all previous scripts from 1.0 such
|
|
|
22 |
as build-key and build-key-server are provided as stubs
|
|
|
23 |
which call pkitool to do the real work.
|
|
|
24 |
|
|
|
25 |
* pkitool has a --batch flag (enabled by default) which generates
|
|
|
26 |
keys/certs without needing any interactive input. pkitool
|
|
|
27 |
can still generate certs/keys using interactive prompting by
|
|
|
28 |
using the --interact flag.
|
|
|
29 |
|
|
|
30 |
* The inherit-inter script has been provided for creating
|
|
|
31 |
a new PKI rooted on an intermediate certificate built within a
|
|
|
32 |
higher-level PKI. See comments in the inherit-inter script
|
|
|
33 |
for more info.
|
|
|
34 |
|
|
|
35 |
* The openssl.cnf file has been modified. pkitool will not
|
|
|
36 |
work with the openssl.cnf file included with previous
|
|
|
37 |
easy-rsa releases.
|
|
|
38 |
|
|
|
39 |
* The vars file has been modified -- the following extra
|
|
|
40 |
variables have been added: EASY_RSA, CA_EXPIRE,
|
|
|
41 |
KEY_EXPIRE.
|
|
|
42 |
|
|
|
43 |
* The make-crl and revoke-crt scripts have been removed and
|
|
|
44 |
are replaced by the revoke-full script.
|
|
|
45 |
|
|
|
46 |
* The "Organizational Unit" X509 field can be set using
|
|
|
47 |
the KEY_OU environmental variable before calling pkitool.
|
|
|
48 |
|
|
|
49 |
* This release only affects the Linux/Unix version of easy-rsa.
|
|
|
50 |
The Windows version (written to use the Windows shell) is unchanged.
|
|
|
51 |
|
|
|
52 |
* Use the revoke-full script to revoke a certificate, and generate
|
|
|
53 |
(or update) the crl.pem file in the keys directory (as set by the
|
|
|
54 |
vars script). Then use "crl-verify crl.pem" in your OpenVPN server
|
|
|
55 |
config file, so that OpenVPN can reject any connections coming from
|
|
|
56 |
clients which present a revoked certificate. Usage for the script is:
|
|
|
57 |
|
|
|
58 |
revoke-full <common-name>
|
|
|
59 |
|
|
|
60 |
Note this this procedure is primarily designed to revoke client
|
|
|
61 |
certificates. You could theoretically use this method to revoke
|
|
|
62 |
server certificates as well, but then you would need to propagate
|
|
|
63 |
the crl.pem file to all clients as well, and have them include
|
|
|
64 |
"crl-verify crl.pem" in their configuration files.
|
|
|
65 |
|
|
|
66 |
* PKCS#11 support was added.
|
|
|
67 |
|
|
|
68 |
* For those interested in using this tool to generate web certificates,
|
|
|
69 |
A variant of the easy-rsa package that allows the creation of multi-domain
|
|
|
70 |
certificates with subjectAltName can be obtained from here:
|
|
|
71 |
|
|
|
72 |
http://www.bisente.com/proyectos/easy-rsa-subjectaltname/
|
|
|
73 |
|
|
|
74 |
INSTALL easy-rsa
|
|
|
75 |
|
|
|
76 |
1. Edit vars.
|
|
|
77 |
2. Set KEY_CONFIG to point to the correct openssl-<version>.cnf
|
|
|
78 |
file included in this distribution.
|
|
|
79 |
3. Set KEY_DIR to point to a directory which will
|
|
|
80 |
contain all keys, certificates, etc. This
|
|
|
81 |
directory need not exist, and if it does,
|
|
|
82 |
it will be deleted with rm -rf, so BE
|
|
|
83 |
CAREFUL how you set KEY_DIR.
|
|
|
84 |
4. (Optional) Edit other fields in vars
|
|
|
85 |
per your site data. You may want to
|
|
|
86 |
increase KEY_SIZE to 2048 if you are
|
|
|
87 |
paranoid and don't mind slower key
|
|
|
88 |
processing, but certainly 1024 is
|
|
|
89 |
fine for testing purposes. KEY_SIZE
|
|
|
90 |
must be compatible across both peers
|
|
|
91 |
participating in a secure SSL/TLS
|
|
|
92 |
connection.
|
|
|
93 |
5. (Optional) If you intend to use PKCS#11,
|
|
|
94 |
install openssl >= 0.9.7, install the
|
|
|
95 |
following components from www.opensc.org:
|
|
|
96 |
- opensc >= 0.10.0
|
|
|
97 |
- engine_pkcs11 >= 0.1.3
|
|
|
98 |
Update the openssl.cnf to load the engine:
|
|
|
99 |
- Uncomment pkcs11 under engine_section.
|
|
|
100 |
- Validate path at dynamic_path under pkcs11_section.
|
|
|
101 |
6. . vars
|
|
|
102 |
7. ./clean-all
|
|
|
103 |
8. As you create certificates, keys, and
|
|
|
104 |
certificate signing requests, understand that
|
|
|
105 |
only .key files should be kept confidential.
|
|
|
106 |
.crt and .csr files can be sent over insecure
|
|
|
107 |
channels such as plaintext email.
|
|
|
108 |
|
|
|
109 |
IMPORTANT
|
|
|
110 |
|
|
|
111 |
To avoid a possible Man-in-the-Middle attack where an authorized
|
|
|
112 |
client tries to connect to another client by impersonating the
|
|
|
113 |
server, make sure to enforce some kind of server certificate
|
|
|
114 |
verification by clients. There are currently four different ways
|
|
|
115 |
of accomplishing this, listed in the order of preference:
|
|
|
116 |
|
|
|
117 |
(1) Build your server certificates with specific key usage and
|
|
|
118 |
extended key usage. The RFC3280 determine that the following
|
|
|
119 |
attributes should be provided for TLS connections:
|
|
|
120 |
|
|
|
121 |
Mode Key usage Extended key usage
|
|
|
122 |
---------------------------------------------------------------------------
|
|
|
123 |
Client digitalSignature TLS Web Client Authentication
|
|
|
124 |
keyAgreement
|
|
|
125 |
digitalSignature, keyAgreement
|
|
|
126 |
|
|
|
127 |
Server digitalSignature, keyEncipherment TLS Web Server Authentication
|
|
|
128 |
digitalSignature, keyAgreement
|
|
|
129 |
|
|
|
130 |
Now add the following line to your client configuration:
|
|
|
131 |
|
|
|
132 |
remote-cert-tls server
|
|
|
133 |
|
|
|
134 |
This will block clients from connecting to any
|
|
|
135 |
server which lacks the required extension designation
|
|
|
136 |
in its certificate, even if the certificate has been
|
|
|
137 |
signed by the CA which is cited in the OpenVPN configuration
|
|
|
138 |
file (--ca directive).
|
|
|
139 |
|
|
|
140 |
(3) Use the --tls-remote directive on the client to
|
|
|
141 |
accept/reject the server connection based on the common
|
|
|
142 |
name of the server certificate.
|
|
|
143 |
|
|
|
144 |
(3) Use a --tls-verify script or plugin to accept/reject the
|
|
|
145 |
server connection based on a custom test of the server
|
|
|
146 |
certificate's embedded X509 subject details.
|
|
|
147 |
|
|
|
148 |
(4) Sign server certificates with one CA and client certificates
|
|
|
149 |
with a different CA. The client config "ca" directive should
|
|
|
150 |
reference the server-signing CA while the server config "ca"
|
|
|
151 |
directive should reference the client-signing CA.
|
|
|
152 |
|
|
|
153 |
NOTES
|
|
|
154 |
|
|
|
155 |
Show certificate fields:
|
|
|
156 |
openssl x509 -in cert.crt -text
|
|
|
157 |
|
|
|
158 |
PKITOOL documentation
|
|
|
159 |
|
|
|
160 |
pkitool 2.0
|
|
|
161 |
Usage: pkitool [options...] [common-name]
|
|
|
162 |
Options:
|
|
|
163 |
--batch : batch mode (default)
|
|
|
164 |
--keysize : Set keysize
|
|
|
165 |
size : size (default=1024)
|
|
|
166 |
--interact : interactive mode
|
|
|
167 |
--server : build server cert
|
|
|
168 |
--initca : build root CA
|
|
|
169 |
--inter : build intermediate CA
|
|
|
170 |
--pass : encrypt private key with password
|
|
|
171 |
--csr : only generate a CSR, do not sign
|
|
|
172 |
--sign : sign an existing CSR
|
|
|
173 |
--pkcs12 : generate a combined PKCS#12 file
|
|
|
174 |
--pkcs11 : generate certificate on PKCS#11 token
|
|
|
175 |
lib : PKCS#11 library
|
|
|
176 |
slot : PKCS#11 slot
|
|
|
177 |
id : PKCS#11 object id (hex string)
|
|
|
178 |
label : PKCS#11 object label
|
|
|
179 |
Standalone options:
|
|
|
180 |
--pkcs11-slots : list PKCS#11 slots
|
|
|
181 |
lib : PKCS#11 library
|
|
|
182 |
--pkcs11-objects : list PKCS#11 token objects
|
|
|
183 |
lib : PKCS#11 library
|
|
|
184 |
slot : PKCS#11 slot
|
|
|
185 |
--pkcs11-init : initialize PKCS#11 token DANGEROUS!!!
|
|
|
186 |
lib : PKCS#11 library
|
|
|
187 |
slot : PKCS#11 slot
|
|
|
188 |
label : PKCS#11 token label
|
|
|
189 |
Notes:
|
|
|
190 |
Please edit the vars script to reflect your configuration,
|
|
|
191 |
then source it with "source ./vars".
|
|
|
192 |
Next, to start with a fresh PKI configuration and to delete any
|
|
|
193 |
previous certificates and keys, run "./clean-all".
|
|
|
194 |
Finally, you can run this tool (pkitool) to build certificates/keys.
|
|
|
195 |
In order to use PKCS#11 interface you must have opensc-0.10.0 or higher.
|
|
|
196 |
Generated files and corresponding OpenVPN directives:
|
|
|
197 |
(Files will be placed in the $KEY_DIR directory, defined in ./vars)
|
|
|
198 |
ca.crt -> root certificate (--ca)
|
|
|
199 |
ca.key -> root key, keep secure (not directly used by OpenVPN)
|
|
|
200 |
.crt files -> client/server certificates (--cert)
|
|
|
201 |
.key files -> private keys, keep secure (--key)
|
|
|
202 |
.csr files -> certificate signing request (not directly used by OpenVPN)
|
|
|
203 |
dh1024.pem or dh2048.pem -> Diffie Hellman parameters (--dh)
|
|
|
204 |
Examples:
|
|
|
205 |
pkitool --initca -> Build root certificate
|
|
|
206 |
pkitool --initca --pass -> Build root certificate with password-protected key
|
|
|
207 |
pkitool --server server1 -> Build "server1" certificate/key
|
|
|
208 |
pkitool client1 -> Build "client1" certificate/key
|
|
|
209 |
pkitool --pass client2 -> Build password-protected "client2" certificate/key
|
|
|
210 |
pkitool --pkcs12 client3 -> Build "client3" certificate/key in PKCS#12 format
|
|
|
211 |
pkitool --csr client4 -> Build "client4" CSR to be signed by another CA
|
|
|
212 |
pkitool --sign client4 -> Sign "client4" CSR
|
|
|
213 |
pkitool --inter interca -> Build an intermediate key-signing certificate/key
|
|
|
214 |
Also see ./inherit-inter script.
|
|
|
215 |
pkitool --pkcs11 /usr/lib/pkcs11/lib1 0 010203 "client5 id" client5
|
|
|
216 |
-> Build "client5" certificate/key in PKCS#11 token
|
|
|
217 |
Typical usage for initial PKI setup. Build myserver, client1, and client2 cert/keys.
|
|
|
218 |
Protect client2 key with a password. Build DH parms. Generated files in ./keys :
|
|
|
219 |
[edit vars with your site-specific info]
|
|
|
220 |
source ./vars
|
|
|
221 |
./clean-all
|
|
|
222 |
./build-dh -> takes a long time, consider backgrounding
|
|
|
223 |
./pkitool --initca
|
|
|
224 |
./pkitool --server myserver
|
|
|
225 |
./pkitool client1
|
|
|
226 |
./pkitool --pass client2
|
|
|
227 |
Typical usage for adding client cert to existing PKI:
|
|
|
228 |
source ./vars
|
|
|
229 |
./pkitool client-new
|