Skip to content

Commit b801b56

Browse files
authored
BYO certs - Changed to support v3 certs with SAN (#1510)
* BYO certs changed to support v3 certs with SAN * Adds note for install openssl on mac
1 parent fe1ab8e commit b801b56

File tree

1 file changed

+41
-10
lines changed
  • daprdocs/content/en/operations/security

1 file changed

+41
-10
lines changed

daprdocs/content/en/operations/security/mtls.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,33 +91,64 @@ kubectl logs --selector=app=dapr-sentry --namespace <DAPR_NAMESPACE>
9191
9292
### Bringing your own certificates
9393
94-
Using Helm, you can provide the PEM encoded root cert, issuer cert and private key that will be populated into the Kubernetes secret.
94+
Using Helm, you can provide the PEM encoded root cert, issuer cert and private key that will be populated into the Kubernetes secret used by Sentry.
9595
96-
*Note: This example uses the step tool to create the certificates. You can install step tool from [here](https://smallstep.com/docs/getting-started/). Windows binaries available [here](https://github.com/smallstep/cli/releases)*
96+
_Note: This example uses the OpenSSL command line tool, this is a widely distributed package, easily installed on Linux via the package manager. On Windows OpenSSL can be installed [using chocolatey](https://community.chocolatey.org/packages/openssl). On MacOS it can be installed using brew `brew install openssl`_
9797
98-
Create the root certificate:
98+
Create config files for generating the certificates, this is necessary for generating v3 certificates with the SAN (Subject Alt Name) extension fields. First save the following to a file named `root.conf`:
9999
100-
```
101-
step certificate create cluster.local ca.crt ca.key --profile root-ca --no-password --insecure
100+
```ini
101+
[req]
102+
distinguished_name = req_distinguished_name
103+
x509_extensions = v3_req
104+
prompt = no
105+
[req_distinguished_name]
106+
C = US
107+
ST = VA
108+
L = Daprville
109+
O = dapr.io/sentry
110+
OU = dapr.io/sentry
111+
CN = cluster.local
112+
[v3_req]
113+
basicConstraints = critical, CA:true
114+
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
115+
extendedKeyUsage = serverAuth, clientAuth
116+
subjectAltName = @alt_names
117+
[alt_names]
118+
DNS.1 = cluster.local
102119
```
103120

104-
Create the issuer certificate:
121+
Repeat this for `issuer.conf`, paste the same contents into the file, but add `pathlen:0` to the end of the basicConstraints line, as shown below:
105122

123+
```ini
124+
basicConstraints = critical, CA:true, pathlen:0
106125
```
107-
step certificate create cluster.local issuer.crt issuer.key --ca ca.crt --ca-key ca.key --profile intermediate-ca --not-after 8760h --no-password --insecure
126+
127+
Run the following to generate the root cert and key
128+
129+
```bash
130+
openssl ecparam -genkey -name prime256v1 | openssl ec -out root.key
131+
openssl req -new -nodes -sha256 -key root.key -out root.csr -config root.conf -extensions v3_req
132+
openssl x509 -req -sha256 -days 365 -in root.csr -signkey root.key -outform PEM -out root.pem -extfile root.conf -extensions v3_req
108133
```
109134

110-
This creates the root and issuer certs and keys.
135+
Next run the following to generate the issuer cert and key:
136+
137+
```bash
138+
openssl ecparam -genkey -name prime256v1 | openssl ec -out issuer.key
139+
openssl req -new -sha256 -key issuer.key -out issuer.csr -config issuer.conf -extensions v3_req
140+
openssl x509 -req -in issuer.csr -CA root.pem -CAkey root.key -CAcreateserial -outform PEM -out issuer.pem -days 365 -sha256 -extfile issuer.conf -extensions v3_req
141+
```
111142

112143
Install Helm and pass the root cert, issuer cert and issuer key to Sentry via configuration:
113144

114145
```bash
115146
kubectl create ns dapr-system
116147

117148
helm install \
118-
--set-file dapr_sentry.tls.issuer.certPEM=issuer.crt \
149+
--set-file dapr_sentry.tls.issuer.certPEM=issuer.pem \
119150
--set-file dapr_sentry.tls.issuer.keyPEM=issuer.key \
120-
--set-file dapr_sentry.tls.root.certPEM=ca.crt \
151+
--set-file dapr_sentry.tls.root.certPEM=root.pem \
121152
--namespace dapr-system \
122153
dapr \
123154
dapr/dapr

0 commit comments

Comments
 (0)