Internal PKI
An Internal PKI consists of
A master-your-own master Certificate Authority (CA) certificate and key which is used to sign each of the server and client certificates.
A separate certificate (also known as a public key) and private key for the server and each client.
The most secure way of doing this is to generate the Certificate Authority keys on a stand-alone (not Internet-connected) machine in a secure location.
Server key
Generate the server certificate and key with:
# ./build-key-server <servername>
Hit enter, and again, and again … including when it asks you to add a pass phrase. This is between servers. When it asks you if you wish to sign, answers yes, and you also want to commit.
Client keys
For security, each client will get its own certificate and key. Per client:
# ./build-key <clientname>
Hit enter, and again, and again … including when it asks you to add a pass phrase. This is between servers. When it asks you if you wish to sign, answers yes, and you also want to commit.
Diffie-Hellman parameters
Use the build-dh
script to determine the encryption parameters necessary for the server end of a SSL/TLS connection:
./build-dh
And the system will get very busy with prime numbers.
Copy keys
In the most secure possible way (for instance with scp
), copy keys and certs to their respective locations.
ca.crt
,dh2048.pem
,<servername>.crt
, and<servername>.key
to/etc/openvpn
on<servername>
ca.crt
,<clientname>.crt
, and<clientname>.key
to/etc/openvpn
on<clientname>
for each client server.
Security improvement
All keys were created, signed and then distributed to the clients. A more secure way would be to generate the keys in their locations, submit a Certificate Signing Request (CSR) to the key-signing machine or transfer the CSR to the offline CA, the key-signing machine could have processed the request and returned a signed certificate which could have been transferred back to the clients. That way, the secret .key files stay on the machine on which they were generated.