2018-02-16 15:17:29 +00:00
|
|
|
# Client Certificate Authentication
|
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
It is possible to enable Client-Certificate Authentication by adding additional annotations to your Ingress Resource.
|
|
|
|
Before getting started you must have the following Certificates Setup:
|
|
|
|
|
|
|
|
1. CA certificate and Key(Intermediate Certs need to be in CA)
|
2018-10-29 06:48:56 +00:00
|
|
|
2. Server Certificate(Signed by CA) and Key (CN should be equal the hostname you will use)
|
2018-10-22 19:15:28 +00:00
|
|
|
3. Client Certificate(Signed by CA) and Key
|
|
|
|
|
2019-04-08 12:35:34 +00:00
|
|
|
For more details on the generation process, checkout the Prerequisite [docs](../../PREREQUISITES.md#client-certificate-authentication).
|
2018-12-18 03:51:56 +00:00
|
|
|
|
|
|
|
You can have as many certificates as you want. If they're in the binary DER format, you can convert them as the following:
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-12-18 03:51:56 +00:00
|
|
|
```bash
|
2019-04-08 12:35:34 +00:00
|
|
|
openssl x509 -in certificate.der -inform der -out certificate.crt -outform pem
|
2018-12-18 03:51:56 +00:00
|
|
|
```
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-12-18 03:51:56 +00:00
|
|
|
Then, you can concatenate them all in only one file, named 'ca.crt' as the following:
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-12-18 03:51:56 +00:00
|
|
|
```bash
|
2019-04-08 12:35:34 +00:00
|
|
|
cat certificate1.crt certificate2.crt certificate3.crt >> ca.crt
|
2018-12-18 03:51:56 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
**Note:** Make sure that the Key Size is greater than 1024 and Hashing Algorithm(Digest) is something better than md5
|
|
|
|
for each certificate generated. Otherwise you will receive an error.
|
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
## Creating Certificate Secrets
|
|
|
|
|
|
|
|
There are many different ways of configuring your secrets to enable Client-Certificate
|
|
|
|
Authentication to work properly.
|
|
|
|
|
|
|
|
1. You can create a secret containing just the CA certificate and another
|
|
|
|
Secret containing the Server Certificate which is Signed by the CA.
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
```bash
|
2019-04-08 12:35:34 +00:00
|
|
|
kubectl create secret generic ca-secret --from-file=ca.crt=ca.crt
|
|
|
|
kubectl create secret generic tls-secret --from-file=tls.crt=server.crt --from-file=tls.key=server.key
|
2018-10-22 19:15:28 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
2. You can create a secret containing CA certificate along with the Server
|
|
|
|
Certificate, that can be used for both TLS and Client Auth.
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
```bash
|
2019-04-08 12:35:34 +00:00
|
|
|
kubectl create secret generic ca-secret --from-file=tls.crt=server.crt --from-file=tls.key=server.key --from-file=ca.crt=ca.crt
|
2018-10-22 19:15:28 +00:00
|
|
|
```
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
Note: The CA Certificate must contain the trusted certificate authority chain to verify client certificates.
|
2019-04-08 12:35:34 +00:00
|
|
|
|
2018-10-09 21:10:56 +00:00
|
|
|
## Setup Instructions
|
2018-02-16 15:17:29 +00:00
|
|
|
|
2018-10-22 19:15:28 +00:00
|
|
|
1. Add the annotations as provided in the [ingress.yaml](ingress.yaml) example to your own ingress resources as required.
|
|
|
|
2. Test by performing a curl against the Ingress Path without the Client Cert and expect a Status Code 400.
|
|
|
|
3. Test by performing a curl against the Ingress Path with the Client Cert and expect a Status Code 200.
|