Skip to content

Handle updated self-signed cert #25

@mblythe86

Description

@mblythe86

I have a script that runs regularly to collect data from my enphase system, and put it into a local DB for my own custom charts.

A couple days ago, this script started failing with errors like this:

 ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: authority and subject key identifier mismatch (_ssl.c:1007)

I eventually realized that this was happening because the self-signed cert that the Envoy gateway was using had been updated. Based on the advice in Documentation/Wrappers/Python/README.adoc and the examples in Python/examples, I called Gateway.trust_gateway() to store the cert for future validation. I moved that captured cert file aside, and the next time I ran my script it succeeded, and created a new configuration/gateway.cer file.

Old cert:

> openssl x509 -noout -text -in configuration/gateway.cer.bak
Certificate:
    Data:
...snip...
        Validity
            Not Before: Aug 28 15:18:27 2023 GMT
            Not After : Aug 27 15:18:27 2024 GMT

New cert:

> openssl x509 -noout -text -in configuration/gateway.cer
Certificate:
    Data:
...snip...
        Validity
            Not Before: Jun 21 11:41:01 2024 GMT
            Not After : Jun 21 11:41:01 2025 GMT

I realize that it is more secure to use this trusted cert, but I'm not sure what a secure way to handle this update would look like. Obviously, accepting any new cert upon validation failure would be no better than not saving the cert in the first place. I had thought that I could reduce the window by only accepting a new cert close to the "Not After" validity date, but in my case, the cert was changed on Aug 21 - over 2 months before it would have expired. I could accept any new cert with the same Issuer/Subject fields, since these seem to be specific to my Envoy gateway (it has my serial number in it). But an attacker could just as easily read the current cert, and spoof a cert with those field values, too.

Please update the documentation to mention this case, and update the examples to gracefully handle it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions