Skip to content

Commit 79c1d5f

Browse files
authored
Merge pull request #427 from sshanks-kx/ssl
add more detail to SSL/TLS instructions
2 parents e60c67c + 1184ef3 commit 79c1d5f

File tree

1 file changed

+43
-13
lines changed

1 file changed

+43
-13
lines changed

docs/kb/ssl.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ A file containing certificate authority (CA) certificates in PEM format. The fil
102102
-----END CERTIFICATE-----
103103
```
104104
sequences. Text is allowed before, between, and after the certificates; it can be used, for example, for descriptions of the certificates.
105+
The CA certificates are used to establish trust, by checking that a certificate presented to a client/server has been issued (directly or indirectly) by a known certificate authority.
105106

106107
Default value is `<OPENSSLDIR>/cacert.pem`
107108

108109
#### SSL_CA_CERT_PATH
109110

110-
A directory containing certificate authority (CA) certificates in PEM format.
111+
A directory containing certificate authority (CA) certificates in PEM format.
112+
The CA certificates are used to establish trust, by checking that a certificate presented to a client/server has been issued (directly or indirectly) by a known certificate authority.
111113

112114
Default value is `<OPENSSLDIR>`
113115

@@ -179,44 +181,72 @@ Configured TLS settings for a kdb+ process can be viewed with [`(-26!)[]`](../ba
179181

180182
## Certificates
181183

182-
If you don’t have a certificate, you can create a self-signed certificate using the `openssl` program. An example script (`makeCerts.sh`) to do so follows; customize as necessary.
184+
If you don’t have a certificate, you can create a self-signed certificate using the `openssl` program.
185+
An example script (`makeCerts.sh`) to do so follows.
186+
Customize as necessary.
183187

184188
```bash
185189
mkdir $HOME/certs && cd $HOME/certs
186190

187191
# create private key for CA (certificate authority)
192+
# ca-private-key.pem will be used by the CA to sign all certificates, must be kept secret
188193
openssl genrsa -out ca-private-key.pem 2048
189-
# create X509 certificate for CA (certificate authority)
194+
# create self-signed X509 certificate, ca-cert.pem, for CA (certificate authority)
190195
openssl req -x509 -new -nodes -key ca-private-key.pem -sha256 -days 365 -out ca-cert.pem -subj /C=US/ST=CA/L=Somewhere/O=Someone/CN=FoobarCA
191196

192-
# create server private key
197+
# create server private key (server-private-key.pem)
193198
openssl genrsa -out server-private-key.pem 2048
194199
# create servers certificate signing request (CSR)
195200
# CSR contains the common name(s) you want your certificate to secure, information about your company, and your public key (taken from provided private key)
201+
# server.csr is used by CA (certificate authority) to issue a certificate for the server
196202
openssl req -new -sha256 -key server-private-key.pem -subj /C=US/ST=CA/L=Somewhere/O=Someone/CN=Foobar -out server.csr
197-
# create X509 certificate for the server (signed by CA)
203+
# create signed X509 certificate for the server (signed by CA)
204+
# server-cert.pem is the public server certificate that validates server has been trusted by the CA (certificate authority)
198205
openssl x509 -req -in server.csr -CA ca-cert.pem -CAkey ca-private-key.pem -CAcreateserial -out server-cert.pem -days 365 -sha256
199206

200-
# create client private key
207+
# create client private key (client-private-key.pem)
201208
openssl genrsa -out client-private-key.pem 2048
202209
# create clients certificate signing request (CSR)
203210
# CSR contains the common name(s) you want your certificate to secure, information about your company, and your public key (taken from provided private key)
211+
# client.csr is used by CA (certificate authority) to issue a certificate for the client
204212
openssl req -new -sha256 -key client-private-key.pem -subj /C=US/ST=CA/L=Somewhere/O=Someone/CN=Foobar -out client.csr
205213
# create X509 certificate for the client (signed by CA)
214+
# client-cert.pem is the public client certificate that validates client has been trusted by the CA (certificate authority)
206215
openssl x509 -req -in client.csr -CA ca-cert.pem -CAkey ca-private-key.pem -CAcreateserial -out client-cert.pem -days 365 -sha256
207216
```
208217

209-
Using this script the server settings can be configured as:
218+
To check contents of generated certificates
219+
220+
```bash
221+
# client signing request (CSR) given to the CA to generate a server certificate
222+
openssl req -in server.csr -noout -text
223+
# server X.509 certificate
224+
openssl x509 -in server-cert.pem -noout -text
225+
# client signing request (CSR) given to the CA to generate a client certificate
226+
openssl req -in client.csr -noout -text
227+
# client X.509 certificate
228+
openssl x509 -in client-cert.pem -noout -text
229+
```
230+
231+
To verify generated certificates against the certificte authority (CA)
232+
```bash
233+
# verify X.509 server certificate
234+
openssl verify -CAfile ca-cert.pem server-cert.pem
235+
# verify X.509 client certificate
236+
openssl verify -CAfile ca-cert.pem client-cert.pem
237+
```
238+
239+
The server environment variables can now be set to the appropriate file locations to permit an SSL/TLS connection
210240
```bash
211-
$ export SSL_CERT_FILE=$HOME/certs/server-cert.pem
212-
$ export SSL_KEY_FILE=$HOME/certs/server-private-key.pem
213-
$ export SSL_CA_CERT_FILE=$HOME/certs/ca-cert.pem
241+
export SSL_CERT_FILE=$HOME/certs/server-cert.pem
242+
export SSL_KEY_FILE=$HOME/certs/server-private-key.pem
243+
export SSL_CA_CERT_FILE=$HOME/certs/ca-cert.pem
214244
```
215245
with the client as:
216246
```bash
217-
$ export SSL_CERT_FILE=$HOME/certs/client-cert.pem
218-
$ export SSL_KEY_FILE=$HOME/certs/client-private-key.pem
219-
$ export SSL_CA_CERT_FILE=$HOME/certs/ca-cert.pem
247+
export SSL_CERT_FILE=$HOME/certs/client-cert.pem
248+
export SSL_KEY_FILE=$HOME/certs/client-private-key.pem
249+
export SSL_CA_CERT_FILE=$HOME/certs/ca-cert.pem
220250
```
221251

222252
:fontawesome-brands-github:

0 commit comments

Comments
 (0)