zigbee-alliance / distributed-compliance-ledger

DCL is a public permissioned ledger framework for certification of device models. The ledger is based on Cosmos SDK and CometBFT (Tendermint).
Apache License 2.0
89 stars 44 forks source link

Improvement Request: Handle Trailing Newline Differences in Certificate Comparison #597

Closed jcps07 closed 2 months ago

jcps07 commented 3 months ago

The DCL currently stores certificates in PEM format as character strings, including newline characters \n. When comparing certificates (i.e., validation of certificates when adding CRL Revocation Point), the presence or absence of a trailing newline can cause two otherwise identical certificates to be treated as different.

Recurrent Issue:

Certificates with a trailing newline at the end are considered different from those without, even if their content is identical.
This discrepancy can lead to issues when comparing certificates that are essentially the same but formatted slightly differently.

Suggested Improvement:

It would be beneficial if the DCL could ignore differences caused by trailing newlines when comparing certificates. Specifically, I'd be good implementing logic that:

  1. Doesn't account for trailing newlines from certificates before comparison.
  2. Compares certificates based on their actual content, disregarding the trailing newline as an insignificant difference. (i.e., look for the content within the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- delimiters)
ashcherbakov commented 2 months ago

PR: https://github.com/zigbee-alliance/distributed-compliance-ledger/pull/600