[OOM-K8S-CERT-EXTERNAL-PROVIDER] Add information about SANs to external provider
[oom/platform/cert-service.git] / docs / sections / cmpv2-cert-provider.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright 2020 NOKIA
4
5 CMPv2 certificate provider
6 ==============================
7
8 General information
9 ------------------------------
10
11 CMPv2 certificate provider is a part of certificate distribution infrastructure in ONAP.
12 The main functionality of the provider is to forward Certificate Signing Requests (CSRs) created by cert-mananger (https://cert-manager.io) to CertServiceAPI.
13
14 Additional information can be found on a dedicated page:  https://wiki.onap.org/display/DW/CertService+and+K8s+Cert-Manager+integration.
15
16
17 CMPv2 Issuer
18 ------------------------------
19
20 In order to be able to request a certificate via CMPv2 provider a *CMPv2Issuer* CRD (Customer Resource Definition) instance has to be created.
21
22 It is important to note that the attribute *kind* has to be set to **CMPv2Issuer**, all other attributes can be set as needed.
23
24 **NOTE: a default instance of CMPv2Issuer is created when installing ONAP via OOM deployment.**
25
26 Here is a definition of a *CMPv2Issuer* provided with ONAP installation:
27
28 .. code-block:: yaml
29
30   apiVersion: certmanager.onap.org/v1
31   kind: CMPv2Issuer
32   metadata:
33     name: cmpv2-issuer-onap
34     namespace: onap
35   spec:
36     url: https://oom-cert-service:8443
37     healthEndpoint: actuator/health
38     certEndpoint: v1/certificate
39     caName: RA
40     certSecretRef:
41       name: cmpv2-issuer-secret
42       certRef: cmpv2Issuer-cert.pem
43       keyRef: cmpv2Issuer-key.pem
44       cacertRef: cacert.pem
45
46
47 Certificate enrolling
48 ------------------------------
49
50 In order to request a certificate a K8s *Certificate* CRD (Custom Resource Definition) has to be created.
51
52 It is important that in the section issuerRef following attributes have those values:
53
54 - group: certmanager.onap.org
55
56 - kind: CMPv2Issuer
57
58 After *Certificate* CRD has been placed cert manager will send a *CSR* (Certificate Sign Request) to CA (Certificate Authority) via CMPv2 provider.
59 Signed certificate as well as trust anchor (CA root certificate) will be stored in the K8s *secret* specified in *Certificate* CRD (see secretName attribute).
60
61 By default certificates will be stored in PEM format. It is possible to get certificates also in JKS and P12 format - see example below - more information can be found on official cert manager page.
62
63 The following SANs types are supported: DNS names, IPs, URIs, emails.
64
65 Here is an example of a *Certificate*:
66
67 .. code-block:: yaml
68
69   apiVersion: cert-manager.io/v1
70   kind: Certificate
71   metadata:
72     name: certificate_name
73     namespace: onap
74   spec:
75     # The secret name to store the signed certificate
76     secretName: secret_name
77     # Common Name
78     commonName: certissuer.onap.org
79     subject:
80       organizations:
81         - Linux-Foundation
82       countries:
83         - US
84       localities:
85         - San-Francisco
86       provinces:
87         - California
88       organizationalUnits:
89         - ONAP
90     # SANs
91     dnsNames:
92       - localhost
93       - certissuer.onap.org
94     ipAddresses:
95       - "127.0.0.1"
96     uris:
97       - onap://cluster.local/
98     emailAddresses:
99       - onap@onap.org
100     # The reference to the CMPv2 issuer
101     issuerRef:
102       group: certmanager.onap.org
103       kind: CMPv2Issuer
104       name: cmpv2-issuer-onap
105     # Section keystores is optional and defines in which format certificates will be stored
106     # If this section is omitted than only PEM format will be present in the secret
107     keystores:
108         jks:
109           create: true
110           passwordSecretRef: # Password used to encrypt the keystore
111             name: certservice-key
112             key: key
113         pkcs12:
114           create: true
115           passwordSecretRef: # Password used to encrypt the keystore
116             name: certservice-key
117             key: key
118
119
120 Here is an example of generated *secret* containing certificates:
121
122 .. code-block:: yaml
123
124     Name:         secret_name
125     Namespace:    onap
126     Labels:       <none>
127     Annotations:  cert-manager.io/alt-names: localhost,certissuer.onap.org
128                   cert-manager.io/certificate-name: certificate_name
129                   cert-manager.io/common-name: certissuer.onap.org
130                   cert-manager.io/ip-sans:
131                   cert-manager.io/issuer-group: certmanager.onap.org
132                   cert-manager.io/issuer-kind: CMPv2Issuer
133                   cert-manager.io/issuer-name: cmpv2-issuer-onap
134                   cert-manager.io/uri-sans:
135
136     Type:  kubernetes.io/tls
137
138     Data
139     ====
140     tls.crt:         1675 bytes  <-- Certificate (PEM)
141     tls.key:         1679 bytes  <-- Private Key (PEM)
142     truststore.jks:  1265 bytes  <-- Trusted anchors (JKS)
143     ca.crt:          1692 bytes  <-- Trusted anchors (PEM)
144     keystore.jks:    3786 bytes  <-- Certificate and Private Key (JKS)
145     keystore.p12:    4047 bytes  <-- Certificate and Private Key (P12)
146
147
148