Add initial 3.x codebase files
This is the initial re-write for the 3.x release series. Signed-off-by: Josh Cepek <josh.cepek@usa.net>
This commit is contained in:
1 parent
346adba3f3
commit
b0494ab243
21 files changed
+2715
No files matched your search
@@ -0,0 +1,109 @@
|
||||
Easy-RSA Advanced Reference
|
||||
=============================
|
||||
|
||||
This is a technical reference for advanced users familiar with PKI processes. If
|
||||
you need a more detailed description, see the `EasyRSA-Readme` or `Intro-To-PKI`
|
||||
docs instead.
|
||||
|
||||
Configuration Reference
|
||||
-----------------------
|
||||
|
||||
#### Configuration Sources
|
||||
|
||||
There are 3 possible ways to perform external configuration of Easy-RSA,
|
||||
selected in the following order where the first defined result wins:
|
||||
|
||||
1. Commmand-line option
|
||||
2. Environmental variable
|
||||
3. 'vars' file, if one is present (see `vars Autodetection` below)
|
||||
4. Built-in default
|
||||
|
||||
Note that not every possible config option can be set everywhere, although any
|
||||
env-var can be added to the 'vars' file even if it's not shown by default.
|
||||
|
||||
#### vars Autodetection
|
||||
|
||||
A 'vars' file is a file named simply `vars` (without an extension) that
|
||||
Easy-RSA will source for configuration. This file is specifically designed
|
||||
*not* to replace variables that have been set with a higher-priority method
|
||||
such as CLI opts or env-vars.
|
||||
|
||||
The following locations are checked, in this order, for a vars file. Only the
|
||||
first one found is used:
|
||||
|
||||
1. File referenced by the --vars CLI option
|
||||
2. The file referenced by the env-var named `EASYRSA_VARS_FILE`
|
||||
3. The `EASYRSA_PKI` directory
|
||||
4. The `EASYRSA` directory
|
||||
5. The location of the easyrsa program (usually will be the same as above)
|
||||
|
||||
Defining the env-var `EASYRSA_NO_VARS` will override the sourcing of the vars
|
||||
file in all cases, including defining it subsequently as a global option.
|
||||
|
||||
#### OpenSSL Config
|
||||
|
||||
Easy-RSA is tightly coupled to the OpenSSL config file (.cnf) for the
|
||||
flexibility the script provides. It is required that this file be available,
|
||||
yet it is possible to use a different OpenSSL config file for a particular
|
||||
PKI, or even change it for a particular invocation.
|
||||
|
||||
The OpenSSL config file is searched for in the following order:
|
||||
|
||||
1. The env-var `EASYRSA_SSL_CONF`
|
||||
2. The 'vars' file (see `vars Autodetection` above)
|
||||
3. The `EASYRSA_PKI` directory with a filename of `openssl-1.0.cnf`
|
||||
4. The `EASYRSA` directory with a filename of `openssl-1.0.cnf`
|
||||
|
||||
Advanced extension handling
|
||||
---------------------------
|
||||
|
||||
Normally the cert extensions are selected by the cert type given on the CLI
|
||||
during signing; this causes the matching file in the x509-types subdirectory to
|
||||
be processed for OpenSSL extensions to add. This can be overridden in a
|
||||
particular PKI by placing another x509-types dir inside the `EASYRSA_PKI` dir
|
||||
which will be used instead.
|
||||
|
||||
The file named `COMMON` in the x509-types dir is appended to every cert type;
|
||||
this is designed for CDP usage, but can be used for any extension that should
|
||||
apply to every signed cert.
|
||||
|
||||
Additionally, the contents of the env-var `EASYRSA_EXTRA_EXTS` is appended with
|
||||
its raw text added to the OpenSSL extensions. The contents are appended as-is to
|
||||
the cert extensions; invalid OpenSSL configs will usually result in failure.
|
||||
|
||||
Environmental Variables Reference
|
||||
---------------------------------
|
||||
|
||||
A list of env-vars, any matching global option (CLI) to set/override it, and a
|
||||
possible terse description is shown below:
|
||||
|
||||
* `EASYRSA` - should point to the Easy-RSA top-level dir, normally $PWD
|
||||
* `EASYRSA_OPENSSL` - command to invoke openssl
|
||||
* `EASYRSA_SSL_CONF` - the openssl config file to use
|
||||
* `EASYRSA_PKI` (CLI: `--pki-dir`) - dir to use to hold all PKI-specific files
|
||||
* `EASYRSA_DN` (CLI: `--dn-mode`) - set to the string `cn_only` or `org` to
|
||||
alter the fields to include in the req DN
|
||||
* `EASYRSA_REQ_COUNTRY` (CLI: `--req-c`) - set the DN country with org mode
|
||||
* `EASYRSA_REQ_PROVINCE` (CLI: `--req-st`) - set the DN state/province with
|
||||
org mode
|
||||
* `EASYRSA_REQ_CITY` (CLI: `--req-city`) - set the DN city/locality with org
|
||||
mode
|
||||
* `EASYRSA_REQ_ORG` (CLI: `--req-org`) - set the DN organization with org mode
|
||||
* `EASYRSA_REQ_EMAIL` (CLI: `--req-email`) - set the DN email with org mode
|
||||
* `EASYRSA_REQ_OU` (CLI: `--req-ou`) - set the DN organizational unit with org
|
||||
mode
|
||||
* `EASYRSA_KEY_SIZE` (CLI: `--key-size`) - set the keysize in bits to generate
|
||||
* `EASYRSA_CA_EXPIRE` (CLI: `--days`) - set the CA expiration time in days
|
||||
* `EASYRSA_CERT_EXPIRE` (CLI: `--days`) - set the issued cert expiration time
|
||||
in days
|
||||
* `EASYRSA_CRL_DAYS` (CLI: `--days`) - set the CRL 'next publish' time in days
|
||||
* `EASYRSA_NS_SUPPORT` (CLI: `--ns-cert`) - string 'yes' or 'no' fields to
|
||||
include the deprecated Netscape extensions
|
||||
* `EASYRSA_NS_COMMENT` (CLI: `--ns-comment`) - string comment to include when
|
||||
using the deprecated Netscape extensions
|
||||
* `EASYRSA_TEMP_FILE` - a temp file to use when dynamically creating req/cert
|
||||
extensions
|
||||
* `EASYRSA_REQ_CN` (CLI: `--req-cn`) - default CN, necessary to set in BATCH
|
||||
mode
|
||||
* `EASYRSA_DIGEST` (CLI: `--digest`) - set a hash diget to use for req/cert
|
||||
signing
|
||||
@@ -0,0 +1,235 @@
|
||||
Easy-RSA 3 Documentation Readme
|
||||
===============================
|
||||
|
||||
This document explains how Easy-RSA 3 and each of its assorted features work.
|
||||
|
||||
If you are looking for a quickstart with less background or detail, an
|
||||
implementation-specific Howto or Readme may be available in this (the `doc/`)
|
||||
directory.
|
||||
|
||||
Easy-RSA Overview
|
||||
-----------------
|
||||
|
||||
Easy-RSA is a utility for managing X.509 PKI, or Public Key Infrastructure. A
|
||||
PKI is based on the notion of trusting a particular authority to authenticate a
|
||||
remote peer; for more background on how PKI works, see the `Intro-To-PKI`
|
||||
document.
|
||||
|
||||
The code is written in platform-neutral POSIX shell, allowing use on a wide
|
||||
range of host systems. The official Windows release also comes bundled with the
|
||||
programs necessary to use Easy-RSA. The shell code attempts to limit the number
|
||||
of external programs it depends on. Crypto-related tasks use openssl as the
|
||||
functional backend.
|
||||
|
||||
Feature Highlights
|
||||
------------------
|
||||
|
||||
Here's a non-exhaustive list of the more notable Easy-RSA features:
|
||||
|
||||
* Easy-RSA is able to manage multiple PKIs, each with their own independent
|
||||
configuration, storage directory, and X.509 extension handling.
|
||||
* Multiple Subject Name (X.509 DN field) formatting options are supported. For
|
||||
VPNs, this means a cleaner commonName only setup can be used.
|
||||
* A single backend is used across all supported platforms, ensuring that no
|
||||
platform is 'left out' of the rich features. Unix-alikes (BSD, Linux, etc)
|
||||
and Windows are all supported.
|
||||
* Easy-RSA's X.509 support includes CRL, CDP, keyUsage/eKu attributes, and
|
||||
additional features. The included support can be changed or extended as an
|
||||
advanced feature.
|
||||
* Interactive and automated (batch) modes of operation
|
||||
* Flexible configuration: features can be enabled through command-line
|
||||
options, environment variables, a config file, or a combination of these.
|
||||
* Built-in defaults allow Easy-RSA to be used without first editing a config
|
||||
file.
|
||||
|
||||
Obtaining and Using Easy-RSA
|
||||
----------------------------
|
||||
|
||||
#### Download and extraction (installation)
|
||||
|
||||
Easy-RSA's main program is a script, supported by a couple of config files. As
|
||||
such, there is no formal "installation" required. Preparing to use Easy-RSA is
|
||||
as simple as downloading the compressed package (.tar.gz for Linux/Unix or
|
||||
.zip for Windows) and extract it to a location of your choosing. There is no
|
||||
compiling or OS-dependent setup required.
|
||||
|
||||
You should install and run Easy-RSA as a non-root (non-Administrator) account
|
||||
as root access is not required.
|
||||
|
||||
#### Running Easy-RSA
|
||||
|
||||
Invoking Easy-RSA is done through your preferred shell. Under Windows, you
|
||||
will use the `EasyRSA Start.bat` program to provide a POSIX-shell environment
|
||||
suitable for using Easy-RSA.
|
||||
|
||||
The basic format for running commands is:
|
||||
|
||||
./easyrsa command [ cmd-opts ]
|
||||
|
||||
where `command` is the name of a command to run, and `cmd-opts` are any
|
||||
options to supply to the command. Some commands have mandatory or optional
|
||||
cmd-opts. Note the leading `./` component of the command: this is required in
|
||||
Unix-like environments and may be a new concept to some Windows users.
|
||||
|
||||
General usage and command help can be shown with:
|
||||
|
||||
./easyrsa help [ command ]
|
||||
|
||||
When run without any command, general usage and a list of available commands
|
||||
are shown; when a command is supplied, detailed help output for that command
|
||||
is shown.
|
||||
|
||||
Configuring Easy-RSA
|
||||
--------------------
|
||||
|
||||
Easy-RSA 3 no longer needs any configuration file prior to operation, unlike
|
||||
earlier versions. However, the `vars.example` file contains many commented
|
||||
options that can be used to control non-default behavior as required. Reading
|
||||
this file will provide an idea of the basic configuration available. Note that
|
||||
a vars file must be named just `vars` (without an extension) to actively use it.
|
||||
|
||||
Additionally, some options can be defined at runtime with options on the
|
||||
command-line. A full list can be shown with:
|
||||
|
||||
./easyrsa help options
|
||||
|
||||
Any of these options can appear before the command as required as shown below:
|
||||
|
||||
./easyrsa [options] command [ cmd-opts ]
|
||||
|
||||
For experts, additional configuration flexibility is available by way of
|
||||
env-vars and custom X.509 extensions. Consult the `EasyRSA-Advanced`
|
||||
documentation for details
|
||||
|
||||
Getting Started: The Basics
|
||||
---------------------------
|
||||
|
||||
Some of the terms used here will be common to those familiar with how PKI works.
|
||||
Instead of describing PKI basics, please consult the document `Intro-To-PKI` if
|
||||
you need a more basic description of how a PKI works.
|
||||
|
||||
#### Creating an Easy-RSA PKI
|
||||
|
||||
In order to do something useful, Easy-RSA needs to first initialize a
|
||||
directory for the PKI. Multiple PKIs can be managed with a single installation
|
||||
of Easy-RSA, but the default directory is called simply "pki" unless otherwise
|
||||
specified.
|
||||
|
||||
To create or clear out (re-initialize) a new PKI, use the command:
|
||||
|
||||
./easyrsa init-pki
|
||||
|
||||
which will create a new, blank PKI structure ready to be used. Once created,
|
||||
this PKI can be used to make a new CA or generate keypairs.
|
||||
|
||||
#### The PKI Directory Structure
|
||||
|
||||
An Easy-RSA PKI contains the following directory structure:
|
||||
|
||||
* private/ - dir with private keys generated on this host
|
||||
* reqs/ - dir with locally generated certificate requests (for a CA imported
|
||||
requests are stored here)
|
||||
|
||||
In a clean PKI no files will exist until, just the bare directories. Commands
|
||||
called later will create the necessary files depending on the operation.
|
||||
|
||||
When building a CA, a number of new files are created by a combination of
|
||||
Easy-RSA and (indirectly) openssl. The important CA files are:
|
||||
|
||||
* `ca.crt` - This is the CA certificate
|
||||
* `index.txt` - This is the "master database" of all issued certs
|
||||
* `serial` - Stores the next serial number (serial numbers increment)
|
||||
* `private/ca.key` - This is the CA private key (security-critical)
|
||||
* `certs_by_serial/` - dir with all CA-signed certs by serial number
|
||||
* `issued/` - dir with issued certs by commonName
|
||||
|
||||
#### After Creating a PKI
|
||||
|
||||
Once you have created a PKI, the next useful step will be to either create a
|
||||
CA, or generate keypairs for a system that needs them. Continue with the
|
||||
relevant section below.
|
||||
|
||||
Using Easy-RSA as a CA
|
||||
----------------------
|
||||
|
||||
#### Building the CA
|
||||
|
||||
In order to sign requests to produce certificates, you need a CA. To create a
|
||||
new CA in a PKI you have created, run:
|
||||
|
||||
./easyrsa build-ca
|
||||
|
||||
Be sure to use a strong passphrase to protect the CA private key. Note that
|
||||
you must supply this passphrase in the future when performing signing
|
||||
operations with your CA, so be sure to remember it.
|
||||
|
||||
During the creation process, you will also select a name for the CA called the
|
||||
Common Name (CN.) This name is purely for display purposes and can be set as
|
||||
you like.
|
||||
|
||||
#### Importing requests to the CA
|
||||
|
||||
Once a CA is built, the PKI is intended to be used to import requests from
|
||||
external systems that are requesting a signed certificate from this CA. In
|
||||
order to sign the request, it must first be imported so Easy-RSA knows about
|
||||
it. This request file must be a standard CSR in PKCS#10 format.
|
||||
|
||||
Regardless of the file name to import, Easy-RSA uses a "short name" defined
|
||||
during import to refer to this request. Importing works like this:
|
||||
|
||||
./easyrsa import-req /path/to/request.req nameOfRequest
|
||||
|
||||
The nameOfRequest should normally refer to the system or person making the
|
||||
request.
|
||||
|
||||
#### Signing a request
|
||||
|
||||
Once Easy-RSA has imported a request, it can be reviewed and signed. Every
|
||||
certificate needs a "type" which controls what extensions the certificate gets
|
||||
Easy-RSA ships with 3 possible types: `client`, `server`, and `ca`, described
|
||||
below:
|
||||
|
||||
* client - A TLS client, suitable for a VPN user or web browser (web client)
|
||||
* server - A TLS server, suitable for a VPN or web server
|
||||
* ca - A subordinate CA, used when chaining multiple CAs together
|
||||
|
||||
Additional types of certs may be defined by local sites as needed; see the
|
||||
advanced documentation for details.
|
||||
|
||||
#### Revoking and publishing CRLs
|
||||
|
||||
If an issue certificate needs to be revoked, this can be done as follows:
|
||||
|
||||
./easyrsa revoke nameOfRequest
|
||||
|
||||
To generate a CRL suitable for publishing to systems that use it, run:
|
||||
|
||||
./easyrsa gen-crl
|
||||
|
||||
Note that this will need to be published or sent to systems that rely on an
|
||||
up-to-date CRL as the certificate is still otherwise valid.
|
||||
|
||||
Using Easy-RSA to generate keypairs & requests
|
||||
----------------------------------------------
|
||||
|
||||
Easy-RSA can generate a keypair and certificate request in PKCS#10 format. This
|
||||
request is what a CA needs in order to generate and return a signed certificate.
|
||||
|
||||
Ideally you should never generate entity keypairs for a client or server in a
|
||||
PKI you are using for your CA. It is best to separate this process and generate
|
||||
keypairs only on the systems you plan to use them.
|
||||
|
||||
Easy-RSA can generate a keypair and request with the following command:
|
||||
|
||||
./easyrsa gen-req nameOfRequest
|
||||
|
||||
You will then be given a chance to modify the Subject details of your request.
|
||||
By default Easy-RSA uses the short name supplied on the command-line, though you
|
||||
are free to change it if necessary. After providing a passphrase and Subject
|
||||
details, the keypair and request files will be shown.
|
||||
|
||||
In order to obtain a signed certificate, the request file must be sent to the
|
||||
CA for signing; this step is obviously not required if a single PKI is used as
|
||||
both the CA and keypair/request generation as the generated request is already
|
||||
"imported."
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
Introduction to PKI
|
||||
===================
|
||||
|
||||
This document is designed to give you a brief introduction into how a PKI, or
|
||||
Public Key Infrastructure, works.
|
||||
|
||||
Terminology Used
|
||||
----------------
|
||||
|
||||
To avoid confusion, the following terms will be used throughout the Easy-RSA
|
||||
documentation. Short forms may be substituted for longer forms as convenient.
|
||||
|
||||
* **PKI**: Public Key Infrastructure. This describes the collection of files
|
||||
and associations between the CA, keypairs, requests, and certificates.
|
||||
* **CA**: Certificate Authority. This is the "master cert" at the root of a
|
||||
PKI.
|
||||
* **cert**: Certificate. A certificate is a request that has been signed by a
|
||||
CA. The certificate contains the public key, some details describing the
|
||||
cert itself, and a digital signature from the CA.
|
||||
* **request**: Certificate Request (optionally 'req'.) This is a request for a
|
||||
certificate that is then send to a CA for signing. A request contains the
|
||||
desired cert information along with a digital signature from the private
|
||||
key.
|
||||
* **keypair**: A keypair is an asymmetric cryptographic pair of keys. These
|
||||
keys are split into two parts: the public and private keys. The public key
|
||||
is included in a request and certificate.
|
||||
|
||||
The CA
|
||||
------
|
||||
|
||||
The heart of a PKI is the CA, or Certificate Authority, and this is also the
|
||||
most security-sensitive. The CA private key is used to sign all issued
|
||||
certificates, so its security is critical in keeping the entire PKI safe. For
|
||||
this reason, it is highly recommended that the CA PKI structure be kept on a
|
||||
system dedicated for such secure usage; it is not a great idea to keep the CA
|
||||
PKI mixed in with one used to generate end-entity certificates, such as clients
|
||||
or servers (VPN or web servers.)
|
||||
|
||||
To start a new PKI, the CA is first created on the secure environment.
|
||||
Depending on security needs, this could managed under a locked down account,
|
||||
dedicated system, or even a completely offline system or using removable media
|
||||
to improve security (after all, you can't suffer an online break-in if your
|
||||
system or PKI is not online.) The exact steps to create a CA are described in a
|
||||
separate section. When creating a new CA, the CA keypair (private and public
|
||||
keys) are created, as well as the file structure necessary to support signing
|
||||
issued certificates.
|
||||
|
||||
Once a CA has been created, it can receive certificate requests from
|
||||
end-entities. These entity certificates are issued to consumers of X509
|
||||
certificates, such as a client or server of a VPN, web, or email system. The
|
||||
certificate requests and certificates are not security-sensitive, and can be
|
||||
transferred in whatever means convenient, such as email, flash drive, etc. For
|
||||
better security, it is a good idea to verify the received request matches the
|
||||
sender's copy, such as by verifying the expected checksum against the sender's
|
||||
original.
|
||||
|
||||
Keypairs and requests
|
||||
---------------------
|
||||
|
||||
Individual end-entities do not need a full CA set up and will only need to
|
||||
create a keypair and associated certificate request. The private key is not used
|
||||
anywhere except on this entity, and should never leave that system. It is wise
|
||||
to secure this private key with a strong passphrase, because if lost or stolen
|
||||
the holder of the private key can make connections appearing as the certificate
|
||||
holder.
|
||||
|
||||
Once a keypair is generated, the certificate request is created and digitally
|
||||
signed using the private key. This request will be sent to a CA for signing, and
|
||||
a signed certificate will be returned.
|
||||
|
||||
How requests become certificates
|
||||
--------------------------------
|
||||
|
||||
After a CA signs the certificate request, a signed certificate is produced. In
|
||||
this step, the CA's private key is used to digitally sign the entity's public
|
||||
key so that any system trusting the CA certificate can implicitly trust the
|
||||
newly issued certificate. This signed certificate is then sent back to the
|
||||
requesting entity. The issued certificate is not security-sensitive and can be
|
||||
sent over plaintext transmission methods.
|
||||
|
||||
Verifying an issued certificate
|
||||
-------------------------------
|
||||
|
||||
After 2 entities have created keypairs, sent their requests to the CA, and
|
||||
received a copy of their signed certificates and the CA's own certificate, they
|
||||
can mutually authenticate with one-another. This process does not require the 2
|
||||
entities to have previously exchanged any kind of security information directly.
|
||||
|
||||
During a TLS handshake each side of the connection presents their own cert chain
|
||||
to the remote end. Each side checks the validity of the cert received against
|
||||
their own copy of the CA cert. By trusting the CA root cert, the peer they are
|
||||
talking to can be authenticated.
|
||||
|
||||
The remote end proves it "really is" the entity identified by the cert by
|
||||
signing a bit of data using its own private key. Only the holder of the private
|
||||
key is able to do this, allowing the remote end to verify the authenticity of
|
||||
the system being connected to.
|
||||
@@ -0,0 +1,18 @@
|
||||
Easy-RSA 3 TODO / wishlist
|
||||
|
||||
Feature support:
|
||||
* makefile
|
||||
* It may be useful to port the Makefile from the 2.x series
|
||||
* This may be desirable for building and downstream packaging
|
||||
* add pkcs11 support
|
||||
* Much of this may be distro-dependent
|
||||
* Keep platform-specific tools separate from platform-neutral code
|
||||
* add detection for duplicate CN prior to OpenSSL failure
|
||||
* This gets tricky if `updatedb` requires a CA passphrase
|
||||
* It would help to warn users before OpenSSL throws errors
|
||||
|
||||
Longer term wishlist:
|
||||
* Support openssl's -password source mechanism:
|
||||
* allow for batching currently "unbatchable" operations, like pkcs12
|
||||
* support one password input that can apply to multiple operations
|
||||
* support a variety of password sources (interactive, pipe, file, etc)
|
||||
Reference in new issue
Block a user