|
| 1 | +# mTLS |
| 2 | + |
| 3 | + |
| 4 | +## Intro |
| 5 | + |
| 6 | +!!! info |
| 7 | + mTLS encryption support is available beginning with Splunk 10 |
| 8 | + |
| 9 | +Mutual TLS (mTLS) is an extension of the standard TLS protocol that provides mutual authentication between a client and a server. While TLS typically ensures that the client can verify the server’s identity, mTLS requires both parties to verify each other’s identities using digital certificates. In our case client is SC4SNMP and server is Splunk. |
| 10 | + |
| 11 | + |
| 12 | +## How to setup Splunk |
| 13 | + |
| 14 | +!!! info |
| 15 | + If you are using Splunk Cloud, reach out to your administrator to configure mutual TLS (mTLS). |
| 16 | + |
| 17 | +1. Ensure that client and server mTLS certificates are already prepared |
| 18 | + |
| 19 | +2. Update `$SPLUNK_HOME/etc/system/local/server.conf`: |
| 20 | + |
| 21 | +``` |
| 22 | +[sslConfig] |
| 23 | +requireClientCert = true |
| 24 | +[kvstore] |
| 25 | +hostnameOption = fullyqualifiedname |
| 26 | +``` |
| 27 | + |
| 28 | +3. Update `$SPLUNK_HOME/etc/system/local/web.conf`: |
| 29 | + |
| 30 | +``` |
| 31 | +[settings] |
| 32 | +sslPassword = password |
| 33 | +sslRootCAPath = cacert.pem |
| 34 | +enableSplunkWebSSL = true |
| 35 | +``` |
| 36 | + |
| 37 | +4. Restart Splunk: |
| 38 | + |
| 39 | +``` |
| 40 | +$SPLUNK_HOME/bin/splunk restart |
| 41 | +``` |
| 42 | + |
| 43 | +## How to setup SC4SNMP |
| 44 | + |
| 45 | +/// tab | microk8s |
| 46 | +1. Add your **client** mTLS certificates to secrets: |
| 47 | + |
| 48 | +``` |
| 49 | +microk8s kubectl create secret generic mtls -n sc4snmp \ |
| 50 | + --from-file=client.crt=./client.crt \ |
| 51 | + --from-file=client.key=./client.key \ |
| 52 | + --from-file=cacert.pem=./cacert.pem |
| 53 | +``` |
| 54 | + |
| 55 | +2. Use https protocol to communicate with Splunk. To enforce this, set the `splunk.protocol` variable in the configuration file values.yaml: |
| 56 | + |
| 57 | +``` |
| 58 | +splunk: |
| 59 | + protocol: "https" |
| 60 | +``` |
| 61 | + |
| 62 | +3. Add `mtls` section and provide your secret with certificates inside. To do this, update the `values.yaml` file under the splunk section as shown below: |
| 63 | + |
| 64 | +``` |
| 65 | +splunk: |
| 66 | + mtls: |
| 67 | + enabled: true |
| 68 | + secretRef: "mtls" |
| 69 | +``` |
| 70 | + |
| 71 | +4. Redeploy SC4SNMP |
| 72 | +/// |
| 73 | + |
| 74 | +/// tab | docker-compose |
| 75 | +1. Add your **client** mTLS certificates to secrets. To do this, update the docker-compose.yaml file by adding the following section at the end: |
| 76 | + |
| 77 | +``` |
| 78 | +secrets: |
| 79 | + cert: |
| 80 | + file: client.crt |
| 81 | + key: |
| 82 | + file: client.key |
| 83 | + ca: |
| 84 | + file: cacert.pem |
| 85 | +``` |
| 86 | + |
| 87 | +2. To provide the certificates to the `worker-sender` service, update its definition in the `docker-compose.yaml` file as shown below: |
| 88 | + |
| 89 | +``` |
| 90 | +worker-sender: |
| 91 | + environment: |
| 92 | + SPLUNK_HEC_MTLS_CLIENT_CERT: /run/secrets/cert |
| 93 | + SPLUNK_HEC_MTLS_CLIENT_KEY: /run/secrets/key |
| 94 | + SPLUNK_HEC_MTLS_CA_CERT: /run/secrets/ca |
| 95 | + secrets: |
| 96 | + - cert |
| 97 | + - key |
| 98 | + - ca |
| 99 | +``` |
| 100 | +3. Use https protocol to communicate with Splunk. To enforce this, set the `SPLUNK_HEC_PROTOCOL` variable in the configuration file `.env`: |
| 101 | + |
| 102 | +``` |
| 103 | +SPLUNK_HEC_PROTOCOL=https |
| 104 | +``` |
| 105 | + |
| 106 | +4. Redeploy SC4SNMP |
| 107 | +/// |
| 108 | + |
| 109 | + |
| 110 | +## Troubleshooting |
| 111 | + |
| 112 | +1. Double-check that the mTLS certificates you are using are valid. To do this, send a test log message using `curl` in verbose mode, which can help identify any issues with the certificates: |
| 113 | + |
| 114 | +``` |
| 115 | +curl -k https://${HEC_URL} \ |
| 116 | + -H "Authorization: Splunk ${HEC_TOKEN}" \ |
| 117 | + -H "Content-Type: application/json" \ |
| 118 | + -d '{"event": "Hello", "sourcetype": "manual", "host": "myhost", "source": "myapp"}' \ |
| 119 | + --cert client.crt \ |
| 120 | + --key client.key \ |
| 121 | + --cacert cacert.pem \ |
| 122 | + -vvv |
| 123 | +``` |
| 124 | + |
| 125 | +2. Check logs of `worker-sender`. Refer to the instructions on how to configure logs for `kubernetes` or `docker` deployment. |
| 126 | + |
| 127 | + |
0 commit comments