| 1 |
* Use the following `jolokia.properties` to enable SSL authentication. |
| 2 |
Adapt the path accordingly to the certs found in this directory: |
| 3 |
|
| 4 |
``` |
| 5 |
protocol=https |
| 6 |
caCert=cacert.pem |
| 7 |
serverCert=servercert.pem |
| 8 |
serverKey=jserverkey.pem |
| 9 |
useSslClientAuthentication=true |
| 10 |
discoveryEnabled=false |
| 11 |
port=8778 |
| 12 |
host=0.0.0.0 |
| 13 |
``` |
| 14 |
|
| 15 |
* Then start process with Jolokia attached: |
| 16 |
|
| 17 |
``` |
| 18 |
java -javaagent:jolokia.jar=config=jolokia.properties |
| 19 |
``` |
| 20 |
|
| 21 |
* Import client certificate `client.p12` (or you could try it with `server.p12`, too) |
| 22 |
|
| 23 |
* Start Java server and then go to `https://localhost:8778/jolokia/` with the browser (trailing slash important) |
| 24 |
|
| 25 |
# Passwords |
| 26 |
|
| 27 |
When required, the password is "1234" |
| 28 |
|
| 29 |
The server key (serverkey.pem) doesn't have a password |
| 30 |
|
| 31 |
# Howto create certs |
| 32 |
|
| 33 |
``` |
| 34 |
# Start an Open SSL container |
| 35 |
docker run -it --entrypoint sh -v `pwd`:/tmp/ nick81/openssl |
| 36 |
|
| 37 |
# Add to /etc/ssl/openssl.conf |
| 38 |
|
| 39 |
``` |
| 40 |
[ ssl_client ] |
| 41 |
basicConstraints = CA:FALSE |
| 42 |
nsCertType = client |
| 43 |
keyUsage = digitalSignature, keyEncipherment |
| 44 |
extendedKeyUsage = clientAuth |
| 45 |
|
| 46 |
[ ssl_server ] |
| 47 |
basicConstraints = CA:FALSE |
| 48 |
nsCertType = server |
| 49 |
keyUsage = digitalSignature, keyEncipherment |
| 50 |
extendedKeyUsage = serverAuth, nsSGC, msSGC |
| 51 |
``` |
| 52 |
|
| 53 |
# Create CA Key |
| 54 |
cd ca/ |
| 55 |
openssl genrsa -des3 -out key.pem 4096 |
| 56 |
openssl req -new -x509 -days 3650 -key key.pem -out cert.pem |
| 57 |
|
| 58 |
# Create a Server Key & signing request & sign it (with no password on the key) [ note: validity must be *shorter* than CA's ] |
| 59 |
cd server/ |
| 60 |
openssl genrsa -out key.pem -aes128 2048 -days 3600 |
| 61 |
openssl rsa -in key.pem -out key.pem |
| 62 |
openssl req -new -key key.pem -out server.csr -nodes |
| 63 |
openssl x509 -req -extfile ../server.ext -days 2500 -in server.csr -CA ../ca/cert.pem -CAkey ../ca/key.pem -set_serial 01 -out cert.pem -text |
| 64 |
|
| 65 |
# Create a Client Key & signing request & sign it |
| 66 |
cd client/<new-dir>/ |
| 67 |
openssl genrsa -des3 -out key.pem 4096 |
| 68 |
openssl req -new -key key.pem -out client.csr |
| 69 |
openssl x509 -extfile ../../client.ext -req -days 2500 -in client.csr -CA ../../ca/cert.pem -CAkey ../../ca/key.pem -set_serial 02 -out cert.pem -text |
| 70 |
|
| 71 |
# Convert client key to PKCS |
| 72 |
openssl pkcs12 -export -clcerts -in cert.pem -inkey key.pem -out cert.p12 |
| 73 |
|
| 74 |
# Import client key to Browser |
| 75 |
``` |