| 1 | = Mutual TLS Connectivity |
| 2 | This page isn't strictly related to MadMartian Mod but it is necessary for JMX over TLS which we use to monitor MadMartian Mod remotely and securely. |
| 3 | |
| 4 | == Mutual Trust |
| 5 | Both the client (Java Mission Control) and the server (JMX) require three things: |
| 6 | * Self-signed certificate |
| 7 | * Private key |
| 8 | * Trust store |
| 9 | |
| 10 | Self-signed certificates come with a private key (standard PKI), that's the infamous pair right there (you hare). The trust store is for storing the other side's public key. |
| 11 | |
| 12 | == Generate Self-Signed Certificate and Private Key Store |
| 13 | Before we get started it is imperative that the store passwords match the private key passwords, otherwise you'll get unrecoverable key errors when trying to handshake. |
| 14 | |
| 15 | First step is to generate a private key: |
| 16 | {{{#!sh |
| 17 | openssl genrsa -out my.key 2048 |
| 18 | }}} |
| 19 | |
| 20 | Then create the certificate from it: |
| 21 | {{{#!sh |
| 22 | openssl req -x509 -new -nodes -key my.key -sha256 -days 1024 -out my.pem |
| 23 | }}} |
| 24 | |
| 25 | Now create a PKCS12 store from the PKI pair (private key + public cert): |
| 26 | {{{#!sh |
| 27 | openssl pkcs12 -export -name my-side -in my.pem -inkey my.key -out my.p12 |
| 28 | }}} |
| 29 | Replace ''my-side'' with the side that the certificate belongs to ('server' if it will reside on the server and be trusted by the client and vice versa for the client) |
| 30 | |
| 31 | Import the PKCS12 store into a local JKS: |
| 32 | {{{#!sh |
| 33 | keytool -importkeystore -destkeystore my.jks -srckeystore my.p12 -srcstoretype pkcs12 -alias my-side |
| 34 | }}} |
| 35 | |
| 36 | == Trust The Other Side's Certificate |
| 37 | Once you have completed generating certificates for both sides you must now create the trust relationship between them: |
| 38 | |
| 39 | Trust the ''other'' side's certificate: |
| 40 | {{{#!sh |
| 41 | keytool -import -alias other-side -file other.pem -keystore my.trust.jks |
| 42 | }}} |