Skip to content

Commit ddf9c0a

Browse files
committed
Added note to 2-way SSL project
1 parent 3a97ec4 commit ddf9c0a

File tree

1 file changed

+51
-15
lines changed

1 file changed

+51
-15
lines changed

examples/ssl-2way-project/README.md

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,101 @@
1-
This project shows how to create an SSLContext to support deploying modules when 2-way SSL is configured for an app server.
1+
**Note** - if you are using ml-gradle 4.7.0 or higher, you can now configure 2-way SSL via properties instead of having
2+
to construct an `SSLContext` yourself. Please see [the SSL guide](https://github.com/marklogic/ml-gradle/wiki/SSL-guide)
3+
for more information.
24

3-
2-way SSL requires a certificate template to be configured on the MarkLogic app server, "ssl require client certificate" set to true and one or more "ssl client certificate authorities" selected indicating which CAs the client certificates must be signed by.
5+
This project shows how to create an SSLContext to support deploying modules when 2-way SSL is configured for an app
6+
server.
47

5-
Follow instructions here <https://docs.marklogic.com/guide/security/SSL> to setup SSL for the MarkLogic app server.
8+
2-way SSL requires a certificate template to be configured on the MarkLogic app server, "ssl require client certificate"
9+
set to true and one or more "ssl client certificate authorities" selected indicating which CAs the client certificates
10+
must be signed by.
611

7-
To make this work, you will need a certificate authority (CA) that can sign certificates for you. You can either use a known 3rd party or setup your own CA for testing. The rest of the instructions assume that the same CA is used to sign both the client and the server certificates.
12+
Follow instructions here <https://docs.marklogic.com/guide/security/SSL> to setup SSL for the MarkLogic app server.
13+
14+
To make this work, you will need a certificate authority (CA) that can sign certificates for you. You can either use a
15+
known 3rd party or setup your own CA for testing. The rest of the instructions assume that the same CA is used to sign
16+
both the client and the server certificates.
817

918
### Create a server certificate
10-
If the server does not yet have a certificate signed by your CA, you will need to get one and imort it to the server. If you already have server certificated signed by the CA, you can skip this step.
19+
20+
If the server does not yet have a certificate signed by your CA, you will need to get one and imort it to the server. If
21+
you already have server certificated signed by the CA, you can skip this step.
1122

1223
#### Generate and download a certificate request (CSR)
1324

14-
Using the certificate template created above, generate and download a certificate request (CSR). Use that CSR to request a certificate from the CA (or generate one yourself if you have your own CA).
25+
Using the certificate template created above, generate and download a certificate request (CSR). Use that CSR to request
26+
a certificate from the CA (or generate one yourself if you have your own CA).
1527

16-
_Important: Your CSR will have the values for country, state/province, city/town, organization, organizational unit and email address from the certificate template. Your CA will have requirements for what must be in each of those fields. If using your own CA to sign certificates, you will need to configure openssl to be able to process CSRs with the values from the template or set the template values to the values needed for your openssl CA configuration before generating the server CSR._
28+
_Important: Your CSR will have the values for country, state/province, city/town, organization, organizational unit and
29+
email address from the certificate template. Your CA will have requirements for what must be in each of those fields. If
30+
using your own CA to sign certificates, you will need to configure openssl to be able to process CSRs with the values
31+
from the template or set the template values to the values needed for your openssl CA configuration before generating
32+
the server CSR._
1733

1834
The following are helpful resources if considering setting up your own CA for testing:
35+
1936
* <https://www.area536.com/projects/be-your-own-certificate-authority-with-openssl/>
2037
* <https://jamielinux.com/docs/openssl-certificate-authority/create-the-root-pair.html>
2138

2239
#### Import the signed server certificate
23-
Once you have the signed server certificate, import it into the server using the "Import" tab of the certificate template used to generate the CSR.
2440

25-
_Important: The CN in the server cert will be the hostname of the MarkLogic host as seen from the "Hosts" list in the admin UI. This will need to be the hostname you use to connect to MarkLogic if hostname verification is being used._
41+
Once you have the signed server certificate, import it into the server using the "Import" tab of the certificate
42+
template used to generate the CSR.
43+
44+
_Important: The CN in the server cert will be the hostname of the MarkLogic host as seen from the "Hosts" list in the
45+
admin UI. This will need to be the hostname you use to connect to MarkLogic if hostname verification is being used._
2646

2747
### Create a client certificate
28-
Since we are using ml-gradle which uses the MarkLogic Java Client under the covers, we need to use the Java SSL libraries to setup the client SSL configuration. Java uses a "keystore" to manage client and CA certificates. We will use the Java _keytool_ commandline tool to setup a keystore for the client.
48+
49+
Since we are using ml-gradle which uses the MarkLogic Java Client under the covers, we need to use the Java SSL
50+
libraries to setup the client SSL configuration. Java uses a "keystore" to manage client and CA certificates. We will
51+
use the Java _keytool_ commandline tool to setup a keystore for the client.
2952

3053
The follow instructions were guided by the following helpful resources:
54+
3155
* <https://docs.oracle.com/cd/E19509-01/820-3503/ggfen/index.html>
3256
* <https://www.digitalocean.com/community/tutorials/java-keytool-essentials-working-with-java-keystores>
3357

3458
#### Create a keystore
59+
3560
```
3661
keytool -keystore clientkeystore -genkey -alias client
3762
```
3863

39-
You will be prompted for a password for the keystore. Remember this and use it as the `mlKeystorePassword` in the `gradle.properties` file.
64+
You will be prompted for a password for the keystore. Remember this and use it as the `mlKeystorePassword` in
65+
the `gradle.properties` file.
4066

41-
You will be propted to enter values for your name (CN), country, state/province, city/town, organization and organizational unit. Enter values as required by your CA but make sure to use the MarkLogic username that will be using the certificate when propted for "your first and last name". This is the CN stored in the certificate.
67+
You will be propted to enter values for your name (CN), country, state/province, city/town, organization and
68+
organizational unit. Enter values as required by your CA but make sure to use the MarkLogic username that will be using
69+
the certificate when propted for "your first and last name". This is the CN stored in the certificate.
4270

43-
_Important: The CN in client certificate needs to match the user name that you will use to connect to MarkLogic or authentication will fail._
71+
_Important: The CN in client certificate needs to match the user name that you will use to connect to MarkLogic or
72+
authentication will fail._
4473

45-
If you want a different password on the client certificate, enter one when prompted and use this as the `mlKeystoreCertPassword` in the `gradle.properties` file. Otherwise, hit enter to use the same password as the keystore.
74+
If you want a different password on the client certificate, enter one when prompted and use this as
75+
the `mlKeystoreCertPassword` in the `gradle.properties` file. Otherwise, hit enter to use the same password as the
76+
keystore.
4677

47-
When complete, this will create a file called `clientkeystore` (you can name this file whatever you want though). Use this as the value for `mlKeystore` in the `gradle.properties` file.
78+
When complete, this will create a file called `clientkeystore` (you can name this file whatever you want though). Use
79+
this as the value for `mlKeystore` in the `gradle.properties` file.
4880

4981
#### Create a client CSR
82+
5083
```
5184
keytool -keystore clientkeystore -certreq -alias client -keyalg rsa -file client.csr
5285
```
5386

5487
#### Generate a signed client certificate
88+
5589
Use the CSR to have a CA generate a signed client certificate (or generate one using your own CA)
5690

5791
#### Import the CA certificate
92+
5893
```
5994
keytool -import -keystore clientkeystore -file ca.crt -alias theCARoot
6095
```
6196

6297
#### Import the signed client certificate
98+
6399
```
64100
keytool -import -keystore clientkeystore -file client.crt -alias client
65101
```

0 commit comments

Comments
 (0)