Tutorial - Use EJBCA with cert-manager
Learn how to set up EJBCA to issue certificates with the cert-manager using the EJBCA cert-manager external issuer.
cert-manager is an open-source tool for issuing certificates in Kubernetes, integrating with various Public Key Infrastructure (PKI) providers. EJBCA integrates with cert-manager as an external certificate authority, enabling native integration to seamlessly request certificates through cert-manager, issued from EJBCA.
This tutorial is intended for users who wish to issue certificates in Kubernetes that has cert-manager deployed and wants to use a world-class PKI for the certificate issuance. Whether you have standardized on EJBCA as the corporate PKI, need a PKI that runs in a container, or just want to try something new, this integration is for you.
In this tutorial, you will learn how to:
Create keys and certificate signing request (CSR) to request certificates from EJBCA for the EJBCA cert-manager external issuer
Configure a new Registration Authority (RA) role in EJBCA for the cert-manager integration
Deploy cert-manager using a Helm chart
Deploy the EJBCA cert-manager external issuer using a Helm chart
Create an issuer and cluster issuer
Issue certificates with the EJBCA cert-manager external issuer
Sorry, the widget is not supported in this export.
But you can reach it using the following URL:
Prerequisites
Before you begin, you need:
SSH Access to the Kubernetes host.
Internet access to download the cert-manager components, EJBCA cert-manager external issuer container, and helm charts.
An environment configured following the tutorial videos EJBCA - Getting started with Kubernetes.
Step 1 - Configure EJBCA for the cert-manager integration
The cert-manager RA role will allow the EJBCA cert-manager external issuer credential to connect to EJBCA using the REST API to issue and revoke certificates. Follow these steps to create a new role for the cert-manager RA:
Go to the EJBCA Administration user interface using a web browser.
In the EJBCA Admin UI, under System Functions, click Roles and Access Rules.
Next to the list of available roles, click Add.
For Role name, specify RA-cert-manager and click Add.
The Roles Management page now lists the RA-cert-manager role.To update the access rules for the role, click Access Rules for the RA-cert-manager role.
On the Edit Access Rules page, edit the following:
For Role Template, select RA Administrators.
For Authorized CAs, select My PKISubCA-G1.
For End Entity Profiles, select TLS Client Profile and TLS Server Profile.
Click Save to store the updated access rules for the role.
At the top right of the Edit Access Rules page, click Members.
Members are defined by an attribute from the certificate DN and the serial number:
Match with: Select X509:CN, Common name.
CA: Verify that Management CA is selected for the CA to match on.
Match Value: Specify the name value from the certificate, in this example: "cert-manager-ra-01". Note that this is a case-sensitive matching.
Click Add to add the user to the role.
You have now created a role for the cert-manager RA and can continue preparing to deploy the EJBCA cert-manager external issuer and cert-manager.
Step 2 - Create Key, Certificate Signing Request (CSR), and get the certificate for the RA credential
The EJBCA cert-manager external issuer requires a RA credential to connect to EJBCA for issuing and revoking certificates using the REST API. Follow these steps to create the RA credential:
Create the Key and CSR
SSH to the MicroK8s test host that has EJBCA deployed and configured.
In your terminal, enter the following to create a directory to organize all the files for this tutorial:
$mkdircert-managerChange to the cert-manager directory:
$cdcert-managerCreate an OpenSSL configuration file for the EJBCA cert-manager external issuer RA certificate:
$cat> cert-manager-ra-01.conf <<EOF[req]default_bits = 2048prompt = noencrypt_key =yesdistinguished_name = kubelet_servingreq_extensions = v3_req[ kubelet_serving ]C = SEO = Keyfactor CommunityCN = cert-manager-ra-01[ v3_req ]keyUsage = digitalSignatureextendedKeyUsage = clientAuthEOFGenerate the private key and create the CSR using the OpenSSL configuration file:
$ openssl req -new -newkey rsa:2048 -nodes \-keyout cert-manager-ra-01-key.pem -sha256 \-out cert-manager-ra-01.csr -config cert-manager-ra-01.confOutput the contents of the cert-manager-ra-01.csr to use with an upcoming step:
$catcert-manager-ra-01.csrThe output is similar to the following:
-----BEGIN CERTIFICATE REQUEST-----MIICwDCCAagCAQAwSDELMAkGA1UEBhMCU0UxHDAaBgNVBAoME0tleWZhY3RvciBDb21tdW5pdHkxGzAZBgNVBAMMEmNlcnQtbWFuYWdlci1yYS0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM9o0DQ051oUyTRgW8mqOYzVpnJmeUcld0Q4Elg6OpqpWKqcIL0Avk3vsjpBQ9TTm5GUIOMgkaGVwfyiHefT8VReUD2XAouJSe+sINiaTZV4fsEndyQ2DEPhX9Yho2oV7fFMQPJATFZ9cZm4JczKfXtt7ya0aoyYH23thB+ORT6eF0Eiv7bu/kl3/KlZlg0YxZUbYqKZQq4HbYJtXgEWErLVDKrLbyrc9uF85y97eF2N4NmCM+EBS3Smd3UyrGqtuZFhJNF1ST3z9VQoTZBea+ZZO1j5E5fg5i8jZmrp82rjJWx0WlXpwC6lXL70afGDyzQjF/YTTHA1LgsiUpbkkP8CAwEAAaAzMDEGCSqGSIb3DQEJDjEkMCIwCwYDVR0PBAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQC3S/u936GVC8ew2K9WtjhHX92/6UYtJ1VJ5wgyKElepwl4Lsp5i+3MFIFRYlYtypM1p9wZjRRnaBcnwmAsXqoYXjoHo5TXlcDXdxcBGRbuv25MoUCxdqWgDEqK3oui/qD3L/3YYLNpygToaDWFPBop8vEpj8qmjcZ4CVkwSvwELGeihJP0Ja+T+0q1NhnyjnYTXYUawxbND/Ma9OSJHnlCkHdprgZq0JB3H2Zqh1yYU/qxh1HdIqmbiRzvD6OqsY/FwvMUwF23DNu5r7N6urv9/sS+KaCZTx3T7ezpumTihw5jwzifQRKyq0A3yW8FtQ8J1hDXCDAvolLJxlUnDfaV-----END CERTIFICATE REQUEST-----
Submit the CSR to EJBCA to get the certificate
Go to the EJBCA RA Web user interface using a web browser.
Click Make New Request and update the following:
Select RA-Administrator for the Certificate Type.
Select Provided by user for Key-pair generation.
Paste the contents of the cert-manager-ra-01.csr from the terminal window into the CSR text field (the PEM output in the terminal window), such as:
-----BEGIN CERTIFICATE REQUEST-----MIICwDCCAagCAQAwSDELMAkGA1UEBhMCU0UxHDAaBgNVBAoME0tleWZhY3RvciBDb21tdW5pdHkxGzAZBgNVBAMMEmNlcnQtbWFuYWdlci1yYS0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM9o0DQ051oUyTRgW8mqOYzVpnJmeUcld0Q4Elg6OpqpWKqcIL0Avk3vsjpBQ9TTm5GUIOMgkaGVwfyiHefT8VReUD2XAouJSe+sINiaTZV4fsEndyQ2DEPhX9Yho2oV7fFMQPJATFZ9cZm4JczKfXtt7ya0aoyYH23thB+ORT6eF0Eiv7bu/kl3/KlZlg0YxZUbYqKZQq4HbYJtXgEWErLVDKrLbyrc9uF85y97eF2N4NmCM+EBS3Smd3UyrGqtuZFhJNF1ST3z9VQoTZBea+ZZO1j5E5fg5i8jZmrp82rjJWx0WlXpwC6lXL70afGDyzQjF/YTTHA1LgsiUpbkkP8CAwEAAaAzMDEGCSqGSIb3DQEJDjEkMCIwCwYDVR0PBAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQC3S/u936GVC8ew2K9WtjhHX92/6UYtJ1VJ5wgyKElepwl4Lsp5i+3MFIFRYlYtypM1p9wZjRRnaBcnwmAsXqoYXjoHo5TXlcDXdxcBGRbuv25MoUCxdqWgDEqK3oui/qD3L/3YYLNpygToaDWFPBop8vEpj8qmjcZ4CVkwSvwELGeihJP0Ja+T+0q1NhnyjnYTXYUawxbND/Ma9OSJHnlCkHdprgZq0JB3H2Zqh1yYU/qxh1HdIqmbiRzvD6OqsY/FwvMUwF23DNu5r7N6urv9/sS+KaCZTx3T7ezpumTihw5jwzifQRKyq0A3yW8FtQ8J1hDXCDAvolLJxlUnDfaV-----END CERTIFICATE REQUEST-----Click Upload CSR.
Enter cert-manager-ra-01 for the Username.
Click Download PEM full chain.
Return to the terminal window and open a new tab or terminal window.
In your terminal, enter the following to upload the cert-manager-ra-01.pem to the MicroK8s VM:
$scpcert-manager-ra-01.pem user@172.16.170.187:~/cert-manager/cert-manager-ra-01.crt
The certificate.pem file is renamed to .crt when uploaded to the K8’s host
Return to the original terminal window opened for connecting to the Kubernetes server.
Output the contents of the cert-manager-ra-01.crt file with the cat command to copy the ManagementCA cert PEM blob:
$catcert-manager-ra-01.crtThe output is similar to the following:
Subject: CN=cert-manager-ra-01,O=Keyfactor Community,C=SEIssuer: CN=ManagementCA,O=Keyfactor Community,C=SE-----BEGIN CERTIFICATE-----MIIEfzCCAmegAwIBAgIUdTaxyI6z9SZTQy6cM9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wFywc/2fd+JJ4oFDEPAklM+L+LtmLkhyLHtZzACO0LeSUnmVVInfQPT1uEtpL0pmbAbXspNf0nDzSxVhnr/dvN1xfKkFnTc2yvxyZ83Yu1DzDnLgu2HsP/1veyr6E8z8iD7o61CbSt/WiBeEDYNDgs8IUWDgVn026pUoTL8/pdtcAc+g+C0cr2ox6W1o4e2inQjYaXu2MlKkaAx4YTakqC1sXlb8NWRk8l7UUil+L0e+mFZDxIW3i8MepgXPDa05m4b1ZoXa3EAR8e2++f8nXqJlcjoKQOLLTP64t2r1pmrCjH+xke47uV36MaqIZ/W8Zx7CW1Cwt4wddzniySUjIfa8oB3OSvoHqx7kLfUvcVQWumG2ETi87VSAePUI1DG4aksqTIJ6ZI87Qd/16OUP+9ivwtyPnlemWoMnLiPu7GNPr-----END CERTIFICATE-----Subject: CN=ManagementCA,O=Keyfactor Community,C=SEIssuer: CN=ManagementCA,O=Keyfactor Community,C=SE-----BEGIN CERTIFICATE-----MIIFdTCCA12gAwIBAgIUWpEFjDfFuGU6I5s/zCpuXrVmZIswDQYJKoZIhvcNAQELBQAwQjEVMBMGA1UEAwwMTWFuYWdlbWVudENBMRwwGgYDVQQKDBNLZXlmYWN0b3IgQ29tbXVuaXR5MQswCQYDVQQGEwJTRTAeFw0yMzAxMTgwODM0MDJaFw0zMzAxMTUwODM0MDFaMEIxFTATBgNVBAMMDE1hbmFnZW1lbnRDQTEcMBoGA1UECgwTS2V5ZmFjdG9yIENvbW11bml0eTELMAkGA1UEBhMCU0UwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIf6n+++qldacqGvWlgiPx7AnSMuremYdrRhoylF+3kJbDFiMpKpVzEaeguionS4uXqErZAzgzcbu6huf4bRscYk04nCgXsFAMItsiEZ314oE4thv8fbPPu4K1joeDgdHv0QhA3dkRUNorH54wOR6gLDzn6nBwePJAoKxhc/WoaONta2/OtHeTemYZOLt+uMY+Hj3o2sMeTm3B/B/ED5BWzVMSPOCCV6qk5/cW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BUWSfGJjg/2PDEdo2cPYCXYU4HueE/SnoUbRh0M34BfaHHt8S/vcEZWSkctJUmRZbTju57FKMlIHcgE5FHN5ahDAiScGgncvFfPKXcEPFh5bhKdhT6FzbKysCoRw16rwhzfsm4X42jvzBEOKpUcFDpRuBJszTk30lhAdmROkG5UTemobyKgDVw50VcFKbMk3Q5Gzs9TZ+uRAWJA7rF6MSc+cSlPqMN+i82CAMeU-----END CERTIFICATE-----
Select the PEM blob for the ManagementCA and copy it:
Subject: CN=ManagementCA,O=Keyfactor Community,C=SEIssuer: CN=ManagementCA,O=Keyfactor Community,C=SE-----BEGIN CERTIFICATE-----MIIFdTCCA12gAwIBAgIUWpEFjDfFuGU6I5s/zCpuXrVmZIswDQYJKoZIhvcNAQELBQAwQjEVMBMGA1UEAwwMTWFuYWdlbWVudENBMRwwGgYDVQQKDBNLZXlmYWN0b3IgQ29tbXVuaXR5MQswCQYDVQQGEwJTRTAeFw0yMzAxMTgwODM0MDJaFw0zMzAxMTUwODM0MDFaMEIxFTATBgNVBAMMDE1hbmFnZW1lbnRDQTEcMBoGA1UECgwTS2V5ZmFjdG9yIENvbW11bml0eTELMAkGA1UEBhMCU0UwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIf6n+++qldacqGvWlgiPx7AnSMuremYdrRhoylF+3kJbDFiMpKpVzEaeguionS4uXqErZAzgzcbu6huf4bRscYk04nCgXsFAMItsiEZ314oE4thv8fbPPu4K1joeDgdHv0QhA3dkRUNorH54wOR6gLDzn6nBwePJAoKxhc/WoaONta2/OtHeTemYZOLt+uMY+Hj3o2sMeTm3B/B/ED5BWzVMSPOCCV6qk5/cW/P2YvWfFHUja8xqqbBuuDZHTuX4X58BsHH+o8bgZjWhdwcZb8Oe2VajFX6DpiBZcESQL+0ir0ZqGzALBc8jADv0VZC0u1Pxj39p19Xosm46jelcH3CBD+65I+1Kg5aQ1tIpBHLvdJEuTX6WkNPMmi0VqawxtlgshlF10kLsHm/r+dlGTQ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cFKbMk3Q5Gzs9TZ+uRAWJA7rF6MSc+cSlPqMN+i82CAMeU-----END CERTIFICATE-----Create the ManagementCA.crt file:
$ vim ManagementCA.crtEnter the letter i to insert text.
Paste the ManagementCA PEM blob into the file:
Subject: CN=ManagementCA,O=Keyfactor Community,C=SEIssuer: CN=ManagementCA,O=Keyfactor Community,C=SE-----BEGIN CERTIFICATE-----MIIFdTCCA12gAwIBAgIUWpEFjDfFuGU6I5s/zCpuXrVmZIswDQYJKoZIhvcNAQELBQAwQjEVMBMGA1UEAwwMTWFuYWdlbWVudENBMRwwGgYDVQQKDBNLZXlmYWN0b3IgQ29tbXVuaXR5MQswCQYDVQQGEwJTRTAeFw0yMzAxMTgwODM0MDJaFw0zMzAxMTUwODM0MDFaMEIxFTATBgNVBAMMDE1hbmFnZW1lbnRDQTEcMBoGA1UECgwTS2V5ZmFjdG9yIENvbW11bml0eTELMAkGA1UEBhMCU0UwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIf6n+++qldacqGvWlgiPx7AnSMuremYdrRhoylF+3kJbDFiMpKpVzEaeguionS4uXqErZAzgzcbu6huf4bRscYk04nCgXsFAMItsiEZ314oE4thv8fbPPu4K1joeDgdHv0QhA3dkRUNorH54wOR6gLDzn6nBwePJAoKxhc/WoaONta2/OtHeTemYZOLt+uMY+Hj3o2sMeTm3B/B/ED5BWzVMSPOCCV6qk5/cW/P2YvWfFHUja8xqqbBuuDZHTuX4X58BsHH+o8bgZjWhdwcZb8Oe2VajFX6DpiBZcESQL+0ir0ZqGzALBc8jADv0VZC0u1Pxj39p19Xosm46jelcH3CBD+65I+1Kg5aQ1tIpBHLvdJEuTX6WkNPMmi0VqawxtlgshlF10kLsHm/r+dlGTQ78EA23JkgglBPovCmWSb6+KJyk/q6dWElqrbdHwieuajb2D9s/P7RDU7h9gSf6C4nbIX1x5H/mpVCdZWDuqL0Y7tn9Kkvhh3TNXZf1TiryJkw3GDxHS88mh+pGEZsnC3hH5rLKj/JFVQtbWeu1QdhI5fFlhPtUjIWeFHbgvMisd4qjouJfhuF2LRfpdn/u52MHTVntVGtGYNV3uUVpVR6YkFH0qGfAqP5clv1qSF5gRANIPVQSpF0wcvTHvgWdv9bOy7a9BLvWFg46Ys4HKWQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNf+MZRDSTxfobte/gWABCwE86DSMB0GA1UdDgQWBBTX/jGUQ0k8X6G7Xv4FgAQsBPOg0jAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAC17+M739nb2AG3bpKObDDlW+fYMdEhXtjQcOvHIUrITKryX3lmHyWDFFgFTeTYcoxq8ywFvpvXz4pHgeFWRZYQw7cSWwH8nJfLE+EJlpYU2yUGto/S8NPXV54dAYNsvQQncQixsIYgxsmX7yIzBt1+v3sLmQlp5CfZRCOxj+2fa9jb/jygdQC3AAS5uT86gYz0YcB5VXQ0+jYWsL7MDwgb8ORcmiugduZ0kgBXd40Qg9bJhfz0N+BKWPTbS4dFst4ey5dndLp4QxWXzTt+gbmOMBpiwB6xxH3hw/LrRBEs7hrhVIlJ76cMx/f/5wERD0qS3uPXpCCtcKDBqHFruOI/NMNEVRFwiVxVD8w1jWYXDUyNVErU0LzqGOkyDuRwEDN8svaKn8+WdyumDB21tTWEbYPbFWc9R2epNj8moBVcfnxwsVP5TCXk6tEEOMkCVLNC3JBUWSfGJjg/2PDEdo2cPYCXYU4HueE/SnoUbRh0M34BfaHHt8S/vcEZWSkctJUmRZbTju57FKMlIHcgE5FHN5ahDAiScGgncvFfPKXcEPFh5bhKdhT6FzbKysCoRw16rwhzfsm4X42jvzBEOKpUcFDpRuBJszTk30lhAdmROkG5UTemobyKgDVw50VcFKbMk3Q5Gzs9TZ+uRAWJA7rF6MSc+cSlPqMN+i82CAMeU-----END CERTIFICATE-----Enter :wq to save and close the file.
The EJBCA cert-manager external issuer RA credential has been created and uploaded to the K8’s server. Continue to the next step to deploy cert-manager and the EJBCA cert-manager external issuer.
Step 3 - Deploy cert-manager
To issue certificates using EJBCA and cert-manager, the cert-manager must be deployed. Using Helm and applying the Kubernetes Custom Resource Definitions (CRDs) gets cert-manager up and running quickly.
To deploy cert-manager, follow these steps:
Continue from the terminal window of the previous step.
Add the cert-manager helm repository:
$ helm repo add jetstack https://charts.jetstack.ioThe output is similar to the following:
"jetstack"has been added to your repositories
Update the helm repository cache:
$ helm repo updateThe output is similar to the following:
Hang tightwhilewe grab the latest from your chart repositories......Successfully got an update from the"hashicorp"chart repository...Successfully got an update from the"jetstack"chart repositoryUpdate Complete. ⎈Happy Helming!⎈
Install the cert-manager Custom Resource Definitions:
$ kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.3/cert-manager.crds.yamlThe output is similar to the following:
customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io configuredcustomresourcedefinition.apiextensions.k8s.io/certificates.cert-manager.io configuredcustomresourcedefinition.apiextensions.k8s.io/challenges.acme.cert-manager.io configuredcustomresourcedefinition.apiextensions.k8s.io/clusterissuers.cert-manager.io configuredcustomresourcedefinition.apiextensions.k8s.io/issuers.cert-manager.io configuredcustomresourcedefinition.apiextensions.k8s.io/orders.acme.cert-manager.io configured
Deploy cert-manager using helm:
$ helminstall\cert-manager jetstack/cert-manager\--namespace cert-manager \--create-namespace \--version v1.13.3The output is similar to the following:
NAME: cert-managerLAST DEPLOYED: Thu Jan 25 10:52:05 2024NAMESPACE: cert-managerSTATUS: deployedREVISION: 1TEST SUITE: NoneNOTES:cert-manager v1.13.3 has been deployed successfully!In order to begin issuing certificates, you will need tosetup a ClusterIssueror Issuer resource (forexample, by creating a'letsencrypt-staging'issuer).More information on the different types of issuers and how to configure themcan be foundinour documentation:https://cert-manager.io/docs/configuration/For information on how to configure cert-manager to automatically provisionCertificatesforIngress resources, take alookat the `ingress-shim`documentation:https://cert-manager.io/docs/usage/ingress/
Deployment of cert-manager is now completed, you can continue to the next step to deploy the EJBCA cert-manager external issuer.
Step 4 - Deploy EJBCA cert-manager external issuer
To complete the integration, the EJBCA cert-manager external issuer container is deployed using Helm. This container is an external issuer for cert-manager which uses the EJBCA REST API to submit certificate requests and revoke certificates.
To deploy the EJBCA cert-manager external issuer, follow these steps:
Continue from the terminal window of the previous step.
Create the name space for the EJBCA cert-manager external issuer:
$ kubectl create namespace ejbca-cert-managerThe output is similar to the following:
namespace/ejbca-cert-managercreated
Create the secret for the cert-manager-ra-01 credential:
$ kubectl -n ejbca-cert-manager create secret tls ejbca-secret --cert=cert-manager-ra-01.crt --key=cert-manager-ra-01-key.pemThe output is similar to the following:
secret/ejbca-secretcreated
Create the secret for the EJBCA TLS chain:
$ kubectl -n ejbca-cert-manager create secret generic ejbca-ca-secret --from-file=ca.crt=ManagementCA.crtThe output is similar to the following:
secret/ejbca-ca-secretcreated
Add the EJBCA cert-manager external issuer helm repository:
$ helm repo add ejbca-issuer https://keyfactor.github.io/ejbca-cert-manager-issuerThe output is similar to the following:
"ejbca-issuer"has been added to your repositories
Update the helm repository cache:
$ helm repo updateThe output is similar to the following:
Hang tightwhilewe grab the latest from your chart repositories......Successfully got an update from the"ejbca-issuer"chart repository...Successfully got an update from the"hashicorp"chart repository...Successfully got an update from the"jetstack"chart repositoryUpdate Complete. ⎈Happy Helming!⎈
Deploy the EJBCA cert-manager external issuer:
$ helminstallejbca-cert-manager-issuer ejbca-issuer/ejbca-cert-manager-issuer--namespace ejbca-cert-manager --setimage.tag="1.3.2"The output is similar to the following:
NAME: ejbca-cert-manager-issuerLAST DEPLOYED: Thu Jan 25 08:52:16 2024NAMESPACE: ejbca-cert-managerSTATUS: deployedREVISION: 1TEST SUITE: None
Create a namespace for issuing certificates with the EJBCA cert-manager external issuer:
$ kubectl create namespace pkirulesThe output is similar to the following:
namespace/pkirulescreated
Create the issuer.yaml file:
cat> issuer.yaml <<EOFapiVersion: ejbca-issuer.keyfactor.com/v1alpha1kind: Issuermetadata:namespace: pkiruleslabels:# Customize to to your deployment, but these are optionalapp.kubernetes.io/name: issuerapp.kubernetes.io/instance: pkirules-tlsapp.kubernetes.io/part-of: ejbca-issuerapp.kubernetes.io/created-by: ejbca-issuername: pkirules-tlsspec:hostname:"ejbca-internal.ejbca-k8s"ejbcaSecretName:"ejbca-secret"certificateAuthorityName:"MyPKISubCA-G1"certificateProfileName:"TLS Server Profile"endEntityProfileName:"TLS Server Profile"caBundleSecretName: ejbca-ca-secretEOFApply the issuer.yaml file to create an issuer in the pkirules namespace:
$ kubectl apply -f issuer.yamlThe output is similar to the following:
issuer.ejbca-issuer.keyfactor.com/pkirules-tlscreated
Create the clusterissuer.yaml file:
$cat> clusterissuer.yaml <<EOFapiVersion: ejbca-issuer.keyfactor.com/v1alpha1kind: ClusterIssuermetadata:namespace: pkiruleslabels:# Customize to to your deployment, but these are optionalapp.kubernetes.io/name: clusterissuerapp.kubernetes.io/instance: clusterissuer-pkirulesapp.kubernetes.io/part-of: ejbca-issuerapp.kubernetes.io/created-by: ejbca-issuername: clusterissuer-pkirulesspec:hostname:"ejbca-internal.ejbca-k8s"ejbcaSecretName:"ejbca-secret"certificateAuthorityName:"MyPKISubCA-G1"certificateProfileName:"TLS Server Profile"endEntityProfileName:"TLS Server Profile"caBundleSecretName: ejbca-ca-secretEOFApply the clusterissuer.yaml to create an issuer that uses EJBCA fro the Kubernetes cluster:
$ kubectl apply -f clusterissuer.yamlThe output is similar to the following:
clusterissuer.ejbca-issuer.keyfactor.com/clusterissuer-pkirulescreated
Get the issuers.ejbca-issuer.keyfactor.com:
$ kubectl -n pkirules get issuers.ejbca-issuer.keyfactor.comThe output is similar to the following:
NAME AGEpkirules-tls 1m
Describe the issuers.ejbca-issuer.keyfactor.com:
$ kubectl -n pkirules describe issuers.ejbca-issuer.keyfactor.comThe output is similar to the following:
Name: pkirules-tlsNamespace: pkirulesLabels: app.kubernetes.io/created-by=ejbca-issuerapp.kubernetes.io/instance=pkirules-tlsapp.kubernetes.io/name=issuerapp.kubernetes.io/part-of=ejbca-issuerAnnotations: <none>API Version: ejbca-issuer.keyfactor.com/v1alpha1Kind: IssuerMetadata:Creation Timestamp: 2024-01-25T14:02:01ZGeneration: 1Managed Fields:API Version: ejbca-issuer.keyfactor.com/v1alpha1Fields Type: FieldsV1fieldsV1:f:metadata:f:annotations:.:f:kubectl.kubernetes.io/last-applied-configuration:f:labels:.:f:app.kubernetes.io/created-by:f:app.kubernetes.io/instance:f:app.kubernetes.io/name:f:app.kubernetes.io/part-of:f:spec:.:f:caBundleSecretName:f:certificateAuthorityName:f:certificateProfileName:f:ejbcaSecretName:f:endEntityProfileName:f:hostname:Manager: kubectl-client-side-applyOperation: UpdateTime: 2024-01-25T14:02:01ZAPI Version: ejbca-issuer.keyfactor.com/v1alpha1Fields Type: FieldsV1fieldsV1:f:status:.:f:conditions:Manager: managerOperation: UpdateSubresource: statusTime: 2024-01-25T14:02:01ZResource Version: 601159UID: 2f35a08b-c2f7-4612-b5be-bafd6bfaa2adSpec:Ca Bundle Secret Name: ejbca-ca-secretCertificate Authority Name: MyPKISubCA-G1Certificate Profile Name: TLS Server ProfileEjbca Secret Name: ejbca-secretEnd Entity Profile Name: TLS Server ProfileHostname: ejbca-internal.ejbca-k8sStatus:Conditions:Last Transition Time: 2024-01-25T14:02:01ZMessage: SuccessReason: ejbca-issuer.IssuerController.ReconcileStatus: TrueType: ReadyEvents: <none>
You now have deployed the EJBCA cert-manager external issuer and can continue with issuing certificates.
Step 5 - Issue certificates with the EJBCA cert-manager external issuer
Now that cert-manager and the EJBCA cert-manager external issuer are deployed and configured, you can issue some certificates. Lets explore issuing a certificate manually, using a certificate object, and deploying a simple deployment that will request a certificate for an ingress.
Manual Issuance
Continue from the terminal window of the previous step.
Create an OpenSSL configuration file to generate TLS certificate CSR:
$ cat > test-cm-01.pkirules.conf <<EOF[ req ]distinguished_name = req_distinguished_namereq_extensions = req_extprompt = no[ req_distinguished_name ]countryName = SEorganizationName = Keyfactor CommunitycommonName = test-cm-01.pkirules[ req_ext ]subjectAltName =@alt_names[alt_names]DNS.1= test-cm.pkirulesEOFGenerate an EC P-256 key using OpenSSL:
$ openssl ecparam -name prime256v1 -genkey -noout -outtest-cm-01.pkirules.keyGenerate a CSR with the EC Key and OpenSSL configuration file:
$ openssl req -new -sha256 -keytest-cm-01.pkirules.key -outtest-cm-01.pkirules.csr -configtest-cm-01.pkirules.confUse base64 to encode the CSR and export it to a variable:
$ CSR64ECODE="$(base64 test-cm-01.pkirules.csr | tr -d \\n)"Create a certificate request YAML file that is used to manually request a certificate with cert-manager:
$cat>test-cm-01.pkirules.yaml <<EOFapiVersion: cert-manager.io/v1kind: CertificateRequestmetadata:name:test-cm-01.pkirulesnamespace: pkirulesspec:request: $CSR64ECODEissuerRef:name: pkirules-tlsgroup: ejbca-issuer.keyfactor.comkind: IssuerEOFApply the test-cm-01.pkirules.yaml file which creates the certificate request with cert-manager:
$ kubectl apply -ftest-cm-01.pkirules.yamlThe output is similar to the following:
certificaterequest.cert-manager.io/test-cm-01.pkirules created
List the certificate requests in the pkirules namespace:
$ kubectl -n pkirules get CertificateRequestThe output is similar to the following:
NAME APPROVED DENIED READY ISSUER REQUESTOR AGEtest-cm-01.pkirules True True pkirules-tls admin 2m18s
Describe the test-cm-01.pkirules certificate request to review the details:
$ kubectl -n pkirules describe CertificateRequest/test-cm-01.pkirulesThe output is similar to the following:
Name:test-cm-01.pkirulesNamespace: pkirulesLabels: <none>Annotations: <none>API Version: cert-manager.io/v1Kind: CertificateRequestMetadata:Creation Timestamp: 2024-01-26T10:29:46ZGeneration: 1Managed Fields:API Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:f:conditions:.:k:{"type":"Approved"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: cert-manager-certificaterequests-approverOperation: UpdateSubresource: statusTime: 2024-01-26T10:29:46ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:metadata:f:annotations:.:f:kubectl.kubernetes.io/last-applied-configuration:f:spec:.:f:issuerRef:.:f:group:f:kind:f:name:f:request:Manager: kubectl-client-side-applyOperation: UpdateTime: 2024-01-26T10:29:46ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:.:f:ca:f:certificate:f:conditions:k:{"type":"Ready"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: managerOperation: UpdateSubresource: statusTime: 2024-01-26T10:29:46ZResource Version: 649945UID: 3d8fffb0-6876-4541-8df2-c8a8ab17ed19Spec:Groups:system:masterssystem:authenticatedIssuer Ref:Group: ejbca-issuer.keyfactor.comKind: IssuerName: pkirules-tlsRequest: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQk1qQ0IyUUlCQURCSk1Rc3dDUVlEVlFRR0V3SlRSVEVjTUJvR0ExVUVDZ3dUUzJWNVptRmpkRzl5SUVOdgpiVzExYm1sMGVURWNNQm9HQTFVRUF3d1RkR1Z6ZEMxamJTMHdNUzV3YTJseWRXeGxjekJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQk5Va29xeHB3MGR5ZEQyWVdHSGN2UUNqS21ZbzdBZnVYK2NZeGpqWW5MZnEKVXpHZzkvTkxYM2VRRVlDd2pNTlQ4djNycVd2a2JmNFNmUWlJV29GSFoxMmdMakFzQmdrcWhraUc5dzBCQ1E0eApIekFkTUJzR0ExVWRFUVFVTUJLQ0VIUmxjM1F0WTIwdWNHdHBjblZzWlhNd0NnWUlLb1pJemowRUF3SURTQUF3ClJRSWdKQjArdCtySmZvNVRVYWVCcnFCU1RUYlZnTGVEeTh3Lzd1bFpNanJtTldnQ0lRRFdpNDJPcURHVVBqOHkKK3RWZmxXWTVWUWEreUQ4T1JURDZKMDZ5NHlKRWZBPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUgUkVRVUVTVC0tLS0tCg==UID: adminUsername: adminStatus:Ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNtVENDQWorZ0F3SUJB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BsQkF3d0NnWUlLd1lCQlFVSApBd0V3TlFZRFZSMGZCQzR3TERBcW9DaWdKb1lrYUhSMGNEb3ZMMjE1TG5CcmFTOWpjbXh6TDAxNVVFdEpVM1ZpClEwRXRSekV1WTNKc01CMEdBMVVkRGdRV0JCVFQ4YTJEUTEwSGZCenhPc05LS3J1NVBGYU5LekFPQmdOVkhROEIKQWY4RUJBTUNCYUF3Q2dZSUtvWkl6ajBFQXdRRFNBQXdSUUlnVGhtdTdsTUFZM092Nnk3SmloWmdHMTZRNzYvdgpzVVlGanlYT1NiVEFUZVFDSVFEK2ZRbldlSWRXeVlhYU1HdElhMnVJbURFTE1PeWN1eFZKRVd3YXYvZ3hTQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KConditions:Last Transition Time: 2024-01-26T10:29:46ZMessage: Certificate request has been approved by cert-manager.ioReason: cert-manager.ioStatus: TrueType: ApprovedLast Transition Time: 2024-01-26T10:29:46ZMessage: SignedReason: IssuedStatus: TrueType: ReadyEvents:Type Reason Age From Message---- ------ ---- ---- -------Normal cert-manager.io 3m57s cert-manager-certificaterequests-approver Certificate request has been approved by cert-manager.io
The certificate can be obtained from the output and decoded with base64 to view:
$echo"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5akNDQW5DZ0F3SUJBZ0lVWStUTkNXdHRLc0RmcXREL0ZpZS9aRSsvYzQ4d0NnWUlLb1pJemowRUF3UXcKU0RFTE1Ba0dBMVVFQmhNQ1UwVXhIREFhQmdOVkJBb01FMHRsZVdaaFkzUnZjaUJEYjIxdGRXNXBkSGt4R3pBWgpCZ05WQkFNTUVrMTVJRkJMU1NCVGRXSWdRMEVnTFNCSE1UQWVGdzB5TkRBeE1qWXhNREU1TkRaYUZ3MHlOVEF4Ck1qTXhNREU1TkRWYU1Fa3hDekFKQmdOVkJBWVRBbE5GTVJ3d0dnWURWUVFLREJOTFpYbG1ZV04wYjNJZ1EyOXQKYlhWdWFYUjVNUnd3R2d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wCgYIKoZIzj0EAwQwSDELMAkGA1UEBhMCU0UxHDAaBgNVBAoME0tleWZhY3RvciBDb21tdW5pdHkxGzAZBgNVBAMMEk15IFBLSSBTdWIgQ0EgLSBHMTAeFw0yNDAxMjYxMDE5NDZaFw0yNTAxMjMxMDE5NDVaMEkxCzAJBgNVBAYTAlNFMRwwGgYDVQQKDBNLZXlmYWN0b3IgQ29tbXVuaXR5MRwwGgYDVQQDDBN0ZXN0LWNtLTAxLnBraXJ1bGVzMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1SSirGnDR3J0PZhYYdy9AKMqZijsB+5f5xjGONict+pTMaD380tfd5ARgLCMw1Py/eupa+Rt/hJ9CIhagUdnXaOCATUwggExMB8GA1UdIwQYMBaAFLDlf3Z04iq4uPhYZTPgYqHKpFPtMGEGCCsGAQUFBwEBBFUwUzAxBggrBgEFBQcwAoYlaHR0cDovL215LnBraS9jZXJ0cy9NeVBLSVN1YkNBLUcxLmNydDAeBggrBgEFBQcwAYYSaHR0cDovL215LnBraS9vY3NwMDAGA1UdEQQpMCeCEHRlc3QtY20ucGtpcnVsZXOCE3Rlc3QtY20tMDEucGtpcnVsZXMwEwYDVR0lBAwwCgYIKwYBBQUHAwEwNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL215LnBraS9jcmxzL015UEtJU3ViQ0EtRzEuY3JsMB0GA1UdDgQWBBTT8a2DQ10HfBzxOsNKKru5PFaNKzAOBgNVHQ8BAf8EBAMCBaAwCgYIKoZIzj0EAwQDSAAwRQIgThmu7lMAY3Ov6y7JihZgG16Q76/vsUYFjyXOSbTATeQCIQD+fQnWeIdWyYaaMGtIa2uImDELMOycuxVJEWwav/gxSA==-----END CERTIFICATE-----
The certificate is ready to use from the manual request.
Certificate Kind Object Request
Create the test-cm-02.pkirules.yaml file to create a certificate with the certificate kind object:
$cat>test-cm-02.pkirules.yaml <<EOFapiVersion: cert-manager.io/v1kind: Certificatemetadata:name:test-cm-02.pkirulesnamespace: pkirulesspec:subject:countries:- SEorganizations:- Keyfactor CommunitycommonName:test-cm-02.pkirules#dnsNames:#- test-cm-02.pkirulesprivateKey:algorithm: ECDSAsize: 256secretName:test-cm-02issuerRef:name: pkirules-tlsgroup: ejbca-issuer.keyfactor.comkind: IssuerEOFApply the test-cm-02.pkirules.yaml file which enrolls for a certificate with cert-manager and creates a secret for the private key:
$ kubectl apply -ftest-cm-02.pkirules.yamlThe output is similar to the following:
certificate.cert-manager.io/test-cm-02.pkirules created
List the certificate requests:
$ kubectl -n pkirules get CertificateRequestThe output is similar to the following:
NAME APPROVED DENIED READY ISSUER REQUESTOR AGEtest-cm-01.pkirules True True pkirules-tls admin 68mtest-cm-02.pkirules-1 True True pkirules-tls system:serviceaccount:cert-manager:cert-manager 4m36s
Describe the test-cm-02.pkirules-1 certificate request:
$ kubectl -n pkirules describe CertificateRequesttest-cm-02.pkirules-1The output is similar to the following:
Name:test-cm-02.pkirules-1Namespace: pkirulesLabels: <none>Annotations: cert-manager.io/certificate-name:test-cm-02.pkirulescert-manager.io/certificate-revision: 1cert-manager.io/private-key-secret-name:test-cm-02.pkirules-qknczAPI Version: cert-manager.io/v1Kind: CertificateRequestMetadata:Creation Timestamp: 2024-01-26T11:33:44ZGeneration: 1Managed Fields:API Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:f:conditions:.:k:{"type":"Approved"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: cert-manager-certificaterequests-approverOperation: UpdateSubresource: statusTime: 2024-01-26T11:33:44ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:metadata:f:annotations:.:f:cert-manager.io/certificate-name:f:cert-manager.io/certificate-revision:f:cert-manager.io/private-key-secret-name:f:ownerReferences:.:k:{"uid":"9298479a-3cc1-4370-9146-a1c361007c4a"}:f:spec:.:f:issuerRef:.:f:group:f:kind:f:name:f:request:Manager: cert-manager-certificates-request-managerOperation: UpdateTime: 2024-01-26T11:33:44ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:.:f:ca:f:certificate:f:conditions:k:{"type":"Ready"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: managerOperation: UpdateSubresource: statusTime: 2024-01-26T11:33:44ZOwner References:API Version: cert-manager.io/v1Block Owner Deletion:trueController:trueKind: CertificateName:test-cm-02.pkirulesUID: 9298479a-3cc1-4370-9146-a1c361007c4aResource Version: 662225UID: 8e9a8b60-07fa-4573-b1fe-23f3e67e2c39Spec:Extra:authentication.kubernetes.io/pod-name:cert-manager-55cf8685cb-tztzkauthentication.kubernetes.io/pod-uid:6c69ccc4-46d3-45fd-a942-ec0df90a7eccGroups:system:serviceaccountssystem:serviceaccounts:cert-managersystem:authenticatedIssuer Ref:Group: ejbca-issuer.keyfactor.comKind: IssuerName: pkirules-tlsRequest: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQklUQ0J5UUlCQURCSk1Rc3dDUVlEVlFRR0V3SlRSVEVjTUJvR0ExVUVDaE1UUzJWNVptRmpkRzl5SUVOdgpiVzExYm1sMGVURWNNQm9HQTFVRUF4TVRkR1Z6ZEMxamJTMHdNaTV3YTJseWRXeGxjekJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkdQWXFsU3hhM0xIUUhCYW9aMkVKNnVxcnNPb2xrQjV1UnBReHJPZzc1SDAKdEUzR3UvNFd5YW9jTVRqTWtPQlBjOGsxcUI0Wm52anozWFREeU5ZYmFKaWdIakFjQmdrcWhraUc5dzBCQ1E0eApEekFOTUFzR0ExVWREd1FFQXdJRm9EQUtCZ2dxaGtqT1BRUURBZ05IQURCRUFpQjE0ckp4YkRaRlhnc2tDRW42Ci9xN1FvdDF5UncyYWxFWHJ4TEcwc1FLWUN3SWdSeTRidnNtdllWQ0laTVBPd0FKWG9GaW12Zk5HZGJOSXRhb1cKNlJVMGZMRT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUgUk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CUWN3QVlZU2FIUjBjRG92TDIxNUxuQnJhUzl2WTNOd01CNEdBMVVkRVFRWE1CV0NFM1JsYzNRdFkyMHQKTURJdWNHdHBjblZzWlhNd0V3WURWUjBsQkF3d0NnWUlLd1lCQlFVSEF3RXdOUVlEVlIwZkJDNHdMREFxb0NpZwpKb1lrYUhSMGNEb3ZMMjE1TG5CcmFTOWpjbXh6TDAxNVVFdEpVM1ZpUTBFdFJ6RXVZM0pzTUIwR0ExVWREZ1FXCkJCUmJDNDJRV2dBNGdwWTdBeU9HU1k2eTJOakpPakFPQmdOVkhROEJBZjhFQkFNQ0JhQXdDZ1lJS29aSXpqMEUKQXdRRFNBQXdSUUloQU9tZWNCejN3YnVxU2psei9PZlNsdDJhOXMzOTMvV05oc2pWOEJ1akRoSE5BaUJ2Y0owNQorWk45UWRmNFEzbDFRY3hmakRnWW1IeWl4SElmci91dlBHbk9Ddz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KConditions:Last Transition Time: 2024-01-26T11:33:44ZMessage: Certificate request has been approved by cert-manager.ioReason: cert-manager.ioStatus: TrueType: ApprovedLast Transition Time: 2024-01-26T11:33:44ZMessage: SignedReason: IssuedStatus: TrueType: ReadyEvents: <none>
List the certificates created:
$ kubectl -n pkirules get certificateThe output is similar to the following:
NAME READY SECRET AGEtest-cm-02.pkirules Truetest-cm-02 9m51s
Describe the test-cm-02.pkirules certificate:
$ kubectl -n pkirules describe certificatetest-cm-02.pkirulesThe output is similar to the following:
Name:test-cm-02.pkirulesNamespace: pkirulesLabels: <none>Annotations: <none>API Version: cert-manager.io/v1Kind: CertificateMetadata:Creation Timestamp: 2024-01-26T11:33:44ZGeneration: 1Managed Fields:API Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:f:revision:Manager: cert-manager-certificates-issuingOperation: UpdateSubresource: statusTime: 2024-01-26T11:33:44ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:.:f:conditions:.:k:{"type":"Ready"}:.:f:lastTransitionTime:f:message:f:observedGeneration:f:reason:f:status:f:type:f:notAfter:f:notBefore:f:renewalTime:Manager: cert-manager-certificates-readinessOperation: UpdateSubresource: statusTime: 2024-01-26T11:33:44ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:metadata:f:annotations:.:f:kubectl.kubernetes.io/last-applied-configuration:f:spec:.:f:commonName:f:issuerRef:.:f:group:f:kind:f:name:f:privateKey:.:f:algorithm:f:size:f:secretName:f:subject:.:f:countries:f:organizations:Manager: kubectl-client-side-applyOperation: UpdateTime: 2024-01-26T11:33:44ZResource Version: 662231UID: 9298479a-3cc1-4370-9146-a1c361007c4aSpec:Common Name:test-cm-02.pkirulesIssuer Ref:Group: ejbca-issuer.keyfactor.comKind: IssuerName: pkirules-tlsPrivate Key:Algorithm: ECDSASize: 256Secret Name:test-cm-02Subject:Countries:SEOrganizations:Keyfactor CommunityStatus:Conditions:Last Transition Time: 2024-01-26T11:33:44ZMessage: Certificate is up todateand has not expiredObserved Generation: 1Reason: ReadyStatus: TrueType: ReadyNot After: 2025-01-23T11:23:43ZNot Before: 2024-01-26T11:23:44ZRenewal Time: 2024-09-24T11:23:43ZRevision: 1Events: <none>
List the secrets:
$ kubectl -n pkirules get secretsThe output is similar to the following:
NAME TYPE DATA AGEtest-cm-02 kubernetes.io/tls3 13m
Describe the test-cm-02 secret:
$ kubectl -n pkirules describe secretstest-cm-02The output is similar to the following:
Name:test-cm-02Namespace: pkirulesLabels: controller.cert-manager.io/fao=trueAnnotations: cert-manager.io/alt-names:test-cm-02.pkirulescert-manager.io/certificate-name:test-cm-02.pkirulescert-manager.io/common-name:test-cm-02.pkirulescert-manager.io/ip-sans:cert-manager.io/issuer-group: ejbca-issuer.keyfactor.comcert-manager.io/issuer-kind: Issuercert-manager.io/issuer-name: pkirules-tlscert-manager.io/subject-countries: SEcert-manager.io/subject-organizations: Keyfactor Communitycert-manager.io/uri-sans:Type: kubernetes.io/tlsData====ca.crt: 1660 bytestls.crt: 1005 bytestls.key: 227 bytes
The certificate can now be used, for example by mounting the secret into a container
Request Certificate for Ingress Using a Simple Deployment
Create the simple deployment YAML file to deploy a container and issue a certificate to ingress:
$cat> ejbca-cm-issuer-hello-world.yaml <<EOF---apiVersion: apps/v1kind: Deploymentmetadata:name: ejbca-cm-issuer-helloworld-onenamespace: pkirulesspec:replicas: 1selector:matchLabels:app: ejbca-cm-issuer-helloworld-onetemplate:metadata:labels:app: ejbca-cm-issuer-helloworld-onespec:containers:- name: ejbca-cm-issuer-helloworld-oneimage: hashicorp/http-echo:latestports:- containerPort: 80---apiVersion: v1kind: Servicemetadata:name: helloworldnamespace: pkirulesspec:#type: ClusterIPports:- port: 80targetPort: 80protocol: TCPselector:app: ejbca-cm-issuer-helloworld-oneapiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: hellowworld-ingressnamespace: pkirulesannotations:cert-manager.io/issuer:"pkirules-tls"cert-manager.io/issuer-kind:"Issuer"cert-manager.io/issuer-group:"ejbca-issuer.keyfactor.com"cert-manager.io/common-name:"test-cm-03.pkirules"cert-manager.io/subject-organizations:"Keyfactor Community"cert-manager.io/subject-countries:"SE"cert-manager.io/private-key-algorithm:"ECDSA"cert-manager.io/private-key-size:"256"spec:ingressClassName: publictls:- hosts:-test-cm-03.pkirulessecretName:test-cm-03.pkirulesrules:- host:test-cm-03.pkiruleshttp:paths:- path: /pathType: Prefixbackend:service:name: helloworldport:number: 80EOFApply ejbca-cm-issuer-hello-world.yaml file which starts the deployment and requests a certificate for Ingress using cert-manager:
$ kubectl apply -f ejbca-cm-issuer-hello-world.yamlThe output is similar to the following:
deployment.apps/ejbca-cm-issuer-helloworld-onecreatedingress.networking.k8s.io/hellowworld-ingresscreated
List the certificate requests:
$ kubectl -n pkirules get CertificateRequestThe output is similar to the following:
NAME APPROVED DENIED READY ISSUER REQUESTOR AGEtest-cm-01.pkirules True True pkirules-tls admin 177mtest-cm-02.pkirules-1 True True pkirules-tls system:serviceaccount:cert-manager:cert-manager 113mtest-cm-03.pkirules-1 True True pkirules-tls system:serviceaccount:cert-manager:cert-manager 65s
Describe the test-cm-03.pkirules-1 certificate request:
$ kubectl -n pkirules describe CertificateRequesttest-cm-03.pkirules-1The output is similar to the following:
Name:test-cm-03.pkirules-1Namespace: pkirulesLabels: <none>Annotations: cert-manager.io/certificate-name:test-cm-03.pkirulescert-manager.io/certificate-revision: 1cert-manager.io/private-key-secret-name:test-cm-03.pkirules-fkdg8API Version: cert-manager.io/v1Kind: CertificateRequestMetadata:Creation Timestamp: 2024-01-26T13:26:35ZGeneration: 1Managed Fields:API Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:f:conditions:.:k:{"type":"Approved"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: cert-manager-certificaterequests-approverOperation: UpdateSubresource: statusTime: 2024-01-26T13:26:35ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:metadata:f:annotations:.:f:cert-manager.io/certificate-name:f:cert-manager.io/certificate-revision:f:cert-manager.io/private-key-secret-name:f:ownerReferences:.:k:{"uid":"9ec95bfc-a645-417c-9634-8e727bdeacf3"}:f:spec:.:f:issuerRef:.:f:group:f:kind:f:name:f:request:f:usages:Manager: cert-manager-certificates-request-managerOperation: UpdateTime: 2024-01-26T13:26:35ZAPI Version: cert-manager.io/v1Fields Type: FieldsV1fieldsV1:f:status:.:f:ca:f:certificate:f:conditions:k:{"type":"Ready"}:.:f:lastTransitionTime:f:message:f:reason:f:status:f:type:Manager: managerOperation: UpdateSubresource: statusTime: 2024-01-26T13:26:35ZOwner References:API Version: cert-manager.io/v1Block Owner Deletion:trueController:trueKind: CertificateName:test-cm-03.pkirulesUID: 9ec95bfc-a645-417c-9634-8e727bdeacf3Resource Version: 683881UID: 347ccb7b-fb8c-4e26-97da-d22739a565ccSpec:Extra:authentication.kubernetes.io/pod-name:cert-manager-55cf8685cb-tztzkauthentication.kubernetes.io/pod-uid:6c69ccc4-46d3-45fd-a942-ec0df90a7eccGroups:system:serviceaccountssystem:serviceaccounts:cert-managersystem:authenticatedIssuer Ref:Group: ejbca-issuer.keyfactor.comKind: IssuerName: pkirules-tlsRequest: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQlF6Q0I2UUlCQURCSk1Rc3dDUVlEVlFRR0V3SlRSVEVjTUJvR0ExVUVDaE1UUzJWNVptRmpkRzl5SUVOdgpiVzExYm1sMGVURWNNQm9HQTFVRUF4TVRkR1Z6ZEMxamJTMHdNeTV3YTJseWRXeGxjekJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkNJSVhlaTNnd00zc1cwZ0trOUQyQkV5U3E4NDVET29oRVhwblBWODdBbm8KUFRXeE5qMjlzaUVxN1RqR2lLTlhBUGpzRjBqcU1VNFVQbTJxWHlncmdZK2dQakE4QmdrcWhraUc5dzBCQ1E0eApMekF0TUI0R0ExVWRFUVFYTUJXQ0UzUmxjM1F0WTIwdE1ETXVjR3RwY25Wc1pYTXdDd1lEVlIwUEJBUURBZ1dnCk1Bb0dDQ3FHU000OUJBTUNBMGtBTUVZQ0lRRC9kS0E1VEpyYzZxMHhEUEhGNkJLRmppWjVJSkhWY3FDMnQ5TnAKSjQrcnRnSWhBTGxzNVpROGlJbmtHNjZ1NTNYdnUveVdIYzJDbGpCdFk3bFUvdSt2VVVKaQotLS0tLUVORCBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KUID: 9ec1c31a-f7af-486c-b881-92d55dd4da1fUsages:digital signaturekey enciphermentUsername: system:serviceaccount:cert-manager:cert-managerStatus:Ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNtVENDQWorZ0F3SUJBZ0lVSjBlTDlJbmxubWNDRWpxT3pPTmZOdFZ2QVRFd0NnWUlLb1pJemowRUF3UXcKU1RFTE1Ba0dBMVVFQmhNQ1UwVXhIREFhQmdOVkJBb01FMHRsZVdaaFkzUnZjaUJ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zSnNNQjBHQTFVZERnUVdCQlE1OUhCOVFnNEtYNFNNUjVMdDRPbzMybHZCeERBT0JnTlYKSFE4QkFmOEVCQU1DQmFBd0NnWUlLb1pJemowRUF3UURSd0F3UkFJZ0o1STB6UVZNVk8zdy9zSGpCdEdhTEt3Ugo2dnd1QWNQQkErTnNvc3ozbGVnQ0lCNEpOTmpXb3dmMXpKSFRiNkFXUXR4UDlIL2M4aDBiNWY0aDluN3ptVFc3Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0KConditions:Last Transition Time: 2024-01-26T13:26:35ZMessage: Certificate request has been approved by cert-manager.ioReason: cert-manager.ioStatus: TrueType: ApprovedLast Transition Time: 2024-01-26T13:26:35ZMessage: SignedReason: IssuedStatus: TrueType: ReadyEvents:Type Reason Age From Message---- ------ ---- ---- -------Normal cert-manager.io 2m20s cert-manager-certificaterequests-approver Certificate request has been approved by cert-manager.io
Describe the ingress to see that a certificate was created:
$ kubectl -n pkirules describe ingress/hellowworld-ingressThe output is similar to the following:
Name: hellowworld-ingressLabels: <none>Namespace: pkirulesAddress:127.0.0.1Ingress Class:publicDefault backend: <default>TLS:test-cm-03.pkirules terminates test-cm-03.pkirulesRules:Host Path Backends---- ---- --------test-cm-03.pkirules/ helloworld:80(<error: endpoints"helloworld"not found>)Annotations: cert-manager.io/common-name: test-cm-03.pkirulescert-manager.io/issuer: pkirules-tlscert-manager.io/issuer-group: ejbca-issuer.keyfactor.comcert-manager.io/issuer-kind: Issuercert-manager.io/private-key-algorithm: ECDSAcert-manager.io/private-key-size:256cert-manager.io/subject-countries: SEcert-manager.io/subject-organizations: Keyfactor CommunityEvents:Type Reason Age From Message---- ------ ---- ---- -------Normal CreateCertificate 3m17s cert-manager-ingress-shim Successfully created Certificate"test-cm-03.pkirules"Normal Sync 2m19s (x2 over 3m17s) nginx-ingress-controller Scheduledforsync[user@microk8-01cert-manager]$
You now have deployed certificates three different ways using the EJBCA cert-manager external issuer integration.
Next steps
In this tutorial, you learned how to configure EJBCA for the cert-manager integration and issue certificates from EJBCA natively through cert-manager. Three different issuance methods were demonstrated for this integration.
Here are some next steps we recommend:
If you are interested in EJBCA Enterprise, read more on Keyfactor EJBCA Enterprise.
If you are interested in EJBCA Community, check out EJBCA Community vs Enterprise or read more on ejbca.org.
If you are an EJBCA Enterprise customer and need support, visit the Keyfactor Support Portal.
Discuss with the EJBCA Community on GitHub Discussions.