Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

### Changed
- implemented mTLS for Splunk 10

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions charts/splunk-connect-for-snmp/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 1.12.3
version: 1.13.0-beta.1
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.12.3"
appVersion: "1.13.0-beta.1"
#
dependencies:
- name: mongodb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ spec:
env:
{{- include "environmental-variables" . | nindent 12 }}
{{- include "environmental-variables-sender" . | nindent 12 }}
{{- if .Values.splunk.mtls.enabled }}
- name: SPLUNK_HEC_MTLS_CLIENT_CERT
value: /app/hec-mtls/tls.crt
- name: SPLUNK_HEC_MTLS_CLIENT_KEY
value: /app/hec-mtls/tls.key
- name: SPLUNK_HEC_MTLS_CA_CERT
value: /app/hec-mtls/cacert.pem
{{- end }}
{{- if .Values.worker.livenessProbe.enabled }}
livenessProbe:
exec:
Expand All @@ -63,6 +71,11 @@ spec:
periodSeconds: {{ .Values.worker.readinessProbe.periodSeconds }}
{{- end }}
volumeMounts:
{{- if .Values.splunk.mtls.enabled }}
- name: hec-mtls
mountPath: "/app/hec-mtls"
readOnly: true
{{- end }}
- name: config
mountPath: "/app/config"
readOnly: true
Expand Down Expand Up @@ -102,6 +115,11 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.splunk.mtls.enabled }}
- name: hec-mtls
secret:
secretName: {{ .Values.splunk.mtls.secretRef }}
{{- end }}
# You set volumes at the Pod level, then mount them into containers inside that Pod
- name: config
configMap:
Expand Down
12 changes: 12 additions & 0 deletions charts/splunk-connect-for-snmp/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@
},
"metricsIndex": {
"type": "string"
},
"mtls": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean"
},
"secretRef": {
"type": "string"
}
}
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions charts/splunk-connect-for-snmp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ splunk:
# name of the metrics index
metricsIndex: "netmetrics"

# new encryption appeared in Splunk 10
mtls:
enabled: false
# name of existing secret (should be created manully), that will store certs for mTLS
secretRef: ""

################################################################################
# Splunk Observability configuration
################################################################################
Expand Down
4 changes: 2 additions & 2 deletions docker_compose/.env
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Deployment configuration
SC4SNMP_IMAGE=ghcr.io/splunk/splunk-connect-for-snmp/container
SC4SNMP_TAG="1.12.3"
SC4SNMP_TAG="1.13.0-beta.1"
SCHEDULER_CONFIG_FILE_ABSOLUTE_PATH=
TRAPS_CONFIG_FILE_ABSOLUTE_PATH=
INVENTORY_FILE_ABSOLUTE_PATH=
COREFILE_ABS_PATH=
SC4SNMP_VERSION="1.12.3"
SC4SNMP_VERSION="1.13.0-beta.1"

# Network configuration
COREDNS_ADDRESS=172.28.0.255
Expand Down
127 changes: 127 additions & 0 deletions docs/mtls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# mTLS


## Intro

!!! info
mTLS encryption support is available beginning with Splunk 10

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.


## How to setup Splunk

!!! info
If you are using Splunk Cloud, reach out to your administrator to configure mutual TLS (mTLS).

1. Ensure that client and server mTLS certificates are already prepared

2. Update `$SPLUNK_HOME/etc/system/local/server.conf`:

```
[sslConfig]
requireClientCert = true
[kvstore]
hostnameOption = fullyqualifiedname
```

3. Update `$SPLUNK_HOME/etc/system/local/web.conf`:

```
[settings]
sslPassword = password
sslRootCAPath = cacert.pem
enableSplunkWebSSL = true
```

4. Restart Splunk:

```
$SPLUNK_HOME/bin/splunk restart
```

## How to setup SC4SNMP

/// tab | microk8s
1. Add your **client** mTLS certificates to secrets:

```
microk8s kubectl create secret generic mtls -n sc4snmp \
--from-file=client.crt=./client.crt \
--from-file=client.key=./client.key \
--from-file=cacert.pem=./cacert.pem
```

2. Use https protocol to communicate with Splunk. To enforce this, set the `splunk.protocol` variable in the configuration file values.yaml:

```
splunk:
protocol: "https"
```

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:

```
splunk:
mtls:
enabled: true
secretRef: "mtls"
```

4. Redeploy SC4SNMP
///

/// tab | docker-compose
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:

```
secrets:
cert:
file: client.crt
key:
file: client.key
ca:
file: cacert.pem
```

2. To provide the certificates to the `worker-sender` service, update its definition in the `docker-compose.yaml` file as shown below:

```
worker-sender:
environment:
SPLUNK_HEC_MTLS_CLIENT_CERT: /run/secrets/cert
SPLUNK_HEC_MTLS_CLIENT_KEY: /run/secrets/key
SPLUNK_HEC_MTLS_CA_CERT: /run/secrets/ca
secrets:
- cert
- key
- ca
```
3. Use https protocol to communicate with Splunk. To enforce this, set the `SPLUNK_HEC_PROTOCOL` variable in the configuration file `.env`:

```
SPLUNK_HEC_PROTOCOL=https
```

4. Redeploy SC4SNMP
///


## Troubleshooting

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:

```
curl -k https://${HEC_URL} \
-H "Authorization: Splunk ${HEC_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"event": "Hello", "sourcetype": "manual", "host": "myhost", "source": "myapp"}' \
--cert client.crt \
--key client.key \
--cacert cacert.pem \
-vvv
```

2. Check logs of `worker-sender`. Refer to the instructions on how to configure logs for `kubernetes` or `docker` deployment.


3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.blocks.tab:
alternate_style: true

plugins:
- search:
Expand Down Expand Up @@ -96,6 +98,7 @@ nav:
- Releases: "releases.md"
- Request MIB: "mib-request.md"
- Security: "security.md"
- mTLS: "mtls.md"
- Troubleshooting:
- Accessing and configuring logs: "troubleshooting/configuring-logs.md"
- Docker commands: "troubleshooting/docker-commands.md"
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "splunk-connect-for-snmp"
version = "1.12.3"
version = "1.13.0-beta.1"
description = ""
authors = ["omrozowicz-splunk <omrozowicz@splunk.com>"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion splunk_connect_for_snmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#


__version__ = "1.12.3"
__version__ = "1.13.0-beta.1"
26 changes: 25 additions & 1 deletion splunk_connect_for_snmp/splunk/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
SPLUNK_HEC_HOST = os.getenv("SPLUNK_HEC_HOST", "127.0.0.1")
SPLUNK_HEC_PORT = os.getenv("SPLUNK_HEC_PORT", None)
SPLUNK_HEC_PATH = os.getenv("SPLUNK_HEC_PATH", "services/collector")
SPLUNK_HEC_MTLS_CLIENT_CERT = os.getenv("SPLUNK_HEC_MTLS_CLIENT_CERT", None)
SPLUNK_HEC_MTLS_CLIENT_KEY = os.getenv("SPLUNK_HEC_MTLS_CLIENT_KEY", None)
SPLUNK_HEC_MTLS_CA_CERT = os.getenv("SPLUNK_HEC_MTLS_CA_CERT", None)
METRICS_INDEXING_ENABLED = human_bool(os.getenv("METRICS_INDEXING_ENABLED", "false"))

url = {
Expand Down Expand Up @@ -101,10 +104,31 @@
class HECTask(Task):
def __init__(self):
self.session = Session()
self.session.verify = SPLUNK_HEC_TLSVERIFY

# if we have CA cert for verifacation and we are not under insecureSSL mode
if (
SPLUNK_HEC_MTLS_CA_CERT is not None
and os.path.exists(SPLUNK_HEC_MTLS_CA_CERT)
and SPLUNK_HEC_TLSVERIFY
):
self.session.verify = SPLUNK_HEC_MTLS_CA_CERT
else:
self.session.verify = SPLUNK_HEC_TLSVERIFY

self.session.headers = SPLUNK_HEC_HEADERS
self.session.logger = logger

if (
SPLUNK_HEC_MTLS_CLIENT_CERT is not None
and SPLUNK_HEC_MTLS_CLIENT_KEY is not None
and os.path.exists(SPLUNK_HEC_MTLS_CLIENT_CERT)
and os.path.exists(SPLUNK_HEC_MTLS_CLIENT_KEY)
):
self.session.cert = (
SPLUNK_HEC_MTLS_CLIENT_CERT,
SPLUNK_HEC_MTLS_CLIENT_KEY,
)


class PrepareTask(Task):
def __init__(self):
Expand Down
Loading