Manual TLS Certificates
- Canonical Telco
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 108 | 04 Jul 2024 | |
latest/candidate | 108 | 04 Jul 2024 | |
latest/beta | 108 | 04 Jul 2024 | |
latest/edge | 129 | 22 Oct 2024 | |
latest/edge | 128 | 22 Oct 2024 |
juju deploy manual-tls-certificates --channel beta
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
Getting Started
In this tutorial, we will use the Manual TLS Certificates charm to provide certificates to a requiring charm using the TLS Certificates Requirer Operator as our TLS certificates requirer.
1. Install pre-requisites
Install MicroK8s:
sudo snap install microk8s
Enable the hostpath-storage
MicroK8s add-on:
microk8s enable hostpath-storage
Install Juju:
sudo snap install juju
2. Bootstrap a Juju controller
Bootstrap a Juju controller:
juju bootstrap microk8s
Create a Juju model:
juju add-model demo
3. Deploy Manual TLS Certificates
juju deploy manual-tls-certificates
4. Deploy tls-certificates-requirer
juju deploy tls-certificates-requirer
5. Integrate the two charms
Integrate the charms with their tls-certificates interface:
juju integrate manual-tls-certificates tls-certificates-requirer
Wait for both charms to be in the active/idle status.
ubuntu@server:~$ juju status
Model Controller Cloud/Region Version SLA Timestamp
dev microk8s-localhost microk8s/localhost 3.4.0 unsupported 15:31:05-05:00
App Version Status Scale Charm Channel Rev Address Exposed Message
manual-tls-certificates active 1 manual-tls-certificates 0 10.152.183.58 no 1 outstanding requests, use juju actions to provide certificates
tls-certificates-requirer active 1 tls-certificates-requirer edge 45 10.152.183.241 no Certificate request is sent
Unit Workload Agent Address Ports Message
manual-tls-certificates/0* active idle 10.1.182.25 1 outstanding requests, use juju actions to provide certificates
tls-certificates-requirer/0* active idle 10.1.182.40 Certificate request is sent
6. Generate a CA key and certificate with OpenSSL
Create a certs
directory
mkdir certs
Generate a Private Key
openssl genrsa -out certs/ca.key 2048
Generate a CA certificate
openssl req -new -x509 -days 3650 -key certs/ca.key -out certs/ca.crt -subj "/C=US/CN=pizza.com"
7. Retrieve the CSR
Retrieve the Certificate Signing Request (CSR) made by the TLS Certificates requirer and passed to the Manual TLS Certificates:
juju run manual-tls-certificates/leader get-outstanding-certificate-requests --format=json | yq '.manual-tls-certificates/0.results.result' | yq '.[0].csr' > certs/client.csr
8. Sign the certificate
Sign the certificate and provide it to Manual TLS Certificates:
openssl x509 -req -in certs/client.csr -CA certs/ca.crt -CAkey certs/ca.key -CAcreateserial -out certs/client.crt -days 365 -sha256
Provide the certificate to Manual TLS Certificates:
juju run manual-tls-certificates/leader provide-certificate \
certificate="$(base64 -w0 certs/client.crt)" \
ca-certificate="$(base64 -w0 certs/ca.crt)" \
certificate-signing-request="$(base64 -w0 certs/client.csr)"
9. Validate that the certificate was provided correctly
ubuntu@server:~$ juju run tls-certificates-requirer/leader get-certificate
Running operation 81 with 1 task
- task 82 on unit-tls-certificates-requirer-0
Waiting for task 82...
ca-certificate: |-
-----BEGIN CERTIFICATE-----
MIIDIzCCAgugAwIBAgIUMdmiAJ3GwQSNFlyv6WV/+dfHLucwDQYJKoZIhvcNAQEL
BQAwITELMAkGA1UEBhMCVVMxEjAQBgNVBAMMCXBpenphLmNvbTAeFw0yNDAyMjYy
MDM3MDlaFw0zNDAyMjMyMDM3MDlaMCExCzAJBgNVBAYTAlVTMRIwEAYDVQQDDAlw
aXp6YS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQYdSsh37c
t7Dtgbh1jd0Y6VZIlmt5/3lOGJ4vA123tTpf+ll99Dz8KS3E/H/T5WvC4N/n41+l
ZET+SfNr+VcJ6GopjhD/nYjgQL3CuTsFfo40ZZGJXGG2HTZpK9rZ1r6mSK3lmwTj
KtnAE0uwYIErNwJuIXj2d7AyhmqaBGfxU7VrPow3ZT12VxBDxjmIKxNnO1nFOdEX
KoJ6ZyhH4yxZyT9zazqV9e06M1hfOThdXXTXEz5gxnR9IjpgCV8FUsNwBdULqrvi
V2J6sr/WonuFdtHXHiMY3sb8PX2t9ZFDHHCpwX0/TWkqD35uZzPCUbMf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