Encrypt the agent to Zabbix channel with TLS (PSK or certificate) - #235
Open
kroxiksut wants to merge 2 commits into
Open
Encrypt the agent to Zabbix channel with TLS (PSK or certificate)#235kroxiksut wants to merge 2 commits into
kroxiksut wants to merge 2 commits into
Conversation
…ificate, configured by the new [zabbix] tls_* parameters and --zabbix-tls-* options; without them the plain socket of 3.5.17 is kept, version bumped to 3.5.17.1
…1.1.1 in TLS_ENCRYPTION.md, replacing the note that the ctypes path had not been run there
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds optional TLS encryption for the agent to Zabbix server channel, the same two modes the stock
Zabbix agent supports: a pre-shared key (
psk) and certificates (cert).It is configured by new
tls_*parameters in the[zabbix]section and the matching--zabbix-tls-*command line options;packaging/conf/example_linux.confcarries a full example.Why
A Zabbix server with
No encryptiondisabled for a host cannot accept anything from mamonsu today,so on such installations the agent has to be replaced by scripts around
zabbix_sender, even thoughzabbix_senderitself works fine with the very same PSK. This closes that gap.Compatibility
tls_connect = unencryptedis the default. With none of the new parameters set the behaviour isexactly that of 3.5.17: the same plain socket, the same frame byte for byte, the same
failed: Nparsing. No new runtime dependencies. Version bumped to 3.5.17.1.
Implementation notes
mamonsu/lib/senders/tls.pyis a new module holding the two transports;zbx.pyonly picks onein
_setup_tls()/_connect(). The wire format and the queue logic are untouched.sslmodule; on 3.7 to 3.12 libssl throughctypes, using onlythe public OpenSSL API, with no CPython internals involved. Pinned to TLS 1.2.
deliberately not checked, matching what the Zabbix agent does.
plaintext, neither in the daemon nor in
mamonsu upload.Testing
tests/unitgives 35 passed, 2 skipped. The tests need neither docker nor Zabbix, and both files canbe run directly with
python3on a monitored host that has no pytest.They cover a real handshake against
openssl s_serverin both modes with data going both ways; therejection of a wrong PSK, an unknown CA and a mismatching certificate subject; PSK file parsing and
the absence of the secret from error messages; and the unencrypted path staying unchanged.
Run on Linux with Python 3.12 and OpenSSL 3.0.13 (the ctypes path) and on Windows with Python 3.12
(cert mode on the standard library). The
pskmode was then piloted on Astra Linux 1.7.6 withPython 3.7 and OpenSSL 1.1.1, the oldest combination the ctypes path is meant to cover, with metrics
reaching a Zabbix 7.4 server.
Known limitations
psk_use_session); the connection is pinned to TLS 1.2.pskneeds Python 3.13 or newer, as there is no system libssl there.certmode has been verified againstopenssl s_server, not against a production Zabbix server.TLS_ENCRYPTION.mddocuments the setup, both modes and the limitations in full.