-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client certificate validation (mTLS) design proposal #1233
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e6c5ec8
design: Moved mTLS design document from PR #1226
5cc3d09
design; updated tls-client-verification.md
8faeb63
design/tls-client-verification.md; Corrected typo
00f31d6
design/tls-client-verification; Removed XFCC stuff
bab8d40
design/tls-client-verification; removed more XFCC stuff
e6fecd9
Improved background and reason for mTLS
78c3262
design: Added subjectAltNames to configuration
a29b50f
design: Use a valid "subjectAltNames" example
3e3521e
design: described CAs in secrets
e3393f8
design: Updated mTLS examples
206f949
design: mTLS only with CA validation
tsaarni 14c75e6
design: TLS client validation doc updates after review
tsaarni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# External client certificate validation | ||
|
||
Status: Draft | ||
|
||
This document outlines how to add support for authentication of external clients by validating their client certificates. | ||
|
||
## Goals | ||
|
||
- Allow Contour to be used to protect the backend services from access of unauthorized external clients. | ||
- Allow authentication of external clients by having Envoy validate that client certificates are signed by trusted CA (Certificate Authority). | ||
- Allow configuration of trusted CA certificate(s) for validating the client certificates. | ||
|
||
## Non Goals | ||
|
||
- Fine grained authorization on level of individual request (example of non-goal: only client X can access resource Y on backend service Z). | ||
|
||
## Background | ||
|
||
In TLS (and HTTPS) often only the client authenticates the server. | ||
TLS supports optional authentication of client. | ||
Client certificate based authentication is typically used in machine-to-machine (M2M) communication e.g. to protect sensitive REST APIs. | ||
The application acting as TLS client authenticates itself towards the TLS server by using x509 certificate and by providing proof of possession of the corresponding private key. | ||
|
||
## High-Level Design | ||
|
||
Envoy supports following options for certificate based client authentication: | ||
|
||
1. Verify that a chain of trust can be established from the presented client certificate to the configured trusted root CA certificate (validation of certificate) | ||
2. In addition to 1, verify that the subject alternative name of the client is one of the names listed in the configuration (validation of client identity) | ||
3. Verify that the client certificate hash or subject public key hash matches with configured hash (hash pinning) | ||
|
||
Option 1) is proposed to be implemented in this document. | ||
It is sufficient for the very simplest authentication use cases. | ||
|
||
At a high level following CRD change is proposed: | ||
|
||
- A new record `clientValidation` is added in `spec.virtualhost.tls` in the `HTTPProxy`. | ||
- The `clientValidation` contains parameter `caSecret` which is a reference to a secret containing trusted CA certificate for validating client certificates. | ||
|
||
Sample YAML | ||
|
||
``` | ||
apiVersion: projectcontour.io/v1 | ||
kind: HTTPProxy | ||
metadata: | ||
name: client-validation-example | ||
namespace: default | ||
spec: | ||
virtualhost: | ||
fqdn: example.com | ||
tls: | ||
secretName: server-credentials | ||
clientValidation: | ||
caSecret: ca-cert-for-client-validation | ||
routes: | ||
- services: | ||
- name: service | ||
port: 80 | ||
``` | ||
|
||
### Trusted CAs in Secrets | ||
|
||
The same approach shall be followed for configuring trusted CA certificates as is used currently to store the CA certificates for backend (Envoy upstream) validation: | ||
|
||
The CA certificate is stored in an opaque Kubernetes secret. | ||
The secret will be stored in the same namespace as the corresponding `HTTPProxy` object. | ||
The secret object shall contain entry named `ca.crt`. | ||
The constents shall be the CA certificate in PEM format. | ||
The file may contain "PEM bundle", that is, a list of CA certificates concatenated in single file. | ||
|
||
Example: | ||
``` | ||
% kubectl create secret generic ca-cert-for-client-validation --from-file=./ca.crt | ||
``` | ||
|
||
TLS certificate delegation is not in scope for CA certificates. | ||
|
||
## Detailed Design | ||
|
||
The new configuration item `spec.virtualhost.tls.clientValidation` must be parsed and the CRD's must be updated to validate the new item. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove newline There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
Client certificate validation is enabled in Envoy by setting `auth.DownstreamTlsContext.RequireClientCertificate` value to `true` and by adding trusted CA certificates to `auth.CommonTlsContext.ValidationContextType`. | ||
|
||
## Alternatives Considered | ||
|
||
To use annotation in the `Ingress` object was considered to clumsy. | ||
Annotation must on `Ingress` level and refer to an individual virtual host. | ||
|
||
## Security Considerations | ||
|
||
This proposal assumes that the API server is secure. | ||
If secret or CA data stored in the API server is modified, verification will be ineffective. | ||
|
||
This proposal also assumes that RBAC is in place and only the owners of the Service, Secret, HTTPProxy documents in a namespace can modify them. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!