Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error Status: 200" for ACME certificate #55

Open
f-zappa opened this issue Aug 14, 2024 · 1 comment
Open

"Error Status: 200" for ACME certificate #55

f-zappa opened this issue Aug 14, 2024 · 1 comment

Comments

@f-zappa
Copy link

f-zappa commented Aug 14, 2024

Hi everyone,
I receive an "Error Status: 200" for an ACME cert, although the cert itself is fine. Relevant lines in agent output (when nc'ing it) read like this:

[...]
<<<local:sep(0)>>>
2 "ACME Cert: home.uli-baumann.de" age=0 Error Status: 200
[..]

Once an hour indeed the status turns to "Item not found in monitoring data", probably when the _certificate_parser is called. Same happens when running the agent from the command line using "--debug", and in this case we get a traceback:

Traceback (most recent call last):
  File "/usr/local/etc/rc.syshook.d/start/99-checkmk_agent", line 242, in do_checks
    _lines += getattr(self,_check)()
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/etc/rc.syshook.d/start/99-checkmk_agent", line 1068, in checklocal_acmeclient
    _certificate = self._get_certificate(_cert_info.get("certRefId"))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/etc/rc.syshook.d/start/99-checkmk_agent", line 397, in _get_certificate
    self._certificate_parser()
  File "/usr/local/etc/rc.syshook.d/start/99-checkmk_agent", line 393, in _certificate_parser
    self._certificate_store[_cert.get("refid")] = _cert
                            ^^^^^^^^^
AttributeError: 'str' object has no attribute 'get'

[ .. rest of agent output .. ]

<<<check_mk>>>
FailedPythonPlugins: acmeclient

I looked around the code but don't get why _cert happens to be a string. Maybe someone has an idea how to fix it ...

regards, Uli

@f-zappa f-zappa changed the title "Error Status: 200" for ACME certificateq "Error Status: 200" for ACME certificate Aug 14, 2024
@f-zappa
Copy link
Author

f-zappa commented Aug 19, 2024

OK, had some time today. This effect only occurs if there is only one cert in the store. This for loop expects a list of dicts, but if only one cert exists in store this will be returned as a bare dict.

for _cert in self._config_reader().get("cert"):

Fixed it in #56 with this code (maybe there is a more elegant way, but it fixed my problem):

_certs = self._config_reader().get("cert")
if not isinstance(_certs, list):
    _certs = [_certs]
for _cert in _certs:
    [...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant