Pulp 3.0 remote cert sha256 value doesn't match the input or the cert
When I list a remote, the certs are showed like below
Tied to compare the hexdigest from the ca_cert input string and using openssl command give the same sha256 sum but not match when query pulp.
- openssl dgst -sha256 redhat-uep.pem
This prevent us from comparing the current cert on the system with the cert configured in the pulp. The sha256 sum don't match even the cert is working and configured correctly.
#2 Updated by email@example.com about 1 year ago
This is working fine for me, but the key thing is to remove all trailing whitespace before trying to compute it. Here's the ruby code we're using to do the comparison:
I've uploaded a file that when sent to pulp3 as a remote client cert, comes back with the checksum of 6066b56511a9fabaea2afe86af8a91c75ad2d37bf31891bd493eb8c54f45583d
This file is pre-chomp'd
#4 Updated by binlinf0 about 1 year ago
Your test crt works fine. I just cannot figure out why the redhat-uep.pem on the host doesn't match the sha256sum. I don't see any trailing white space in the pem. Here is my test program and the pem file
$ ./remote.py INPUT 39e65fabe7560d366be3bc4d133bcdef13e30d41ac552a05d182e2f66395422d PULP client_cert b8bd944ff40f1756c08743800453b724f133029725dc762ed9ce6504a828a5ec
#7 Updated by lmjachky about 1 year ago
I confirm that the issue you observed is caused by trailing whitespace characters. In the file redhat-uep.pem, there is present the newline character at the end of the file (even if you do not see it). On the other hand, the file test2.crt does not contain any trailing whitespace characters at all.
This behavior is caused by the implementation of CharField which is inherited by SecretCharField, and the field client_cert is an instance of SecretCharField. CharField removes trailing whitespace characters by default (https://www.django-rest-framework.org/api-guide/fields/#charfield).
def __init__(self, **kwargs): self.allow_blank = kwargs.pop('allow_blank', False) self.trim_whitespace = kwargs.pop('trim_whitespace', True)
def to_internal_value(self, data): # We're lenient with allowing basic numerics to be coerced into strings, # but other types should fail. Eg. unclear if booleans should represent as `true` or `True`, # and composites such as lists are likely user error. if isinstance(data, bool) or not isinstance(data, (str, int, float,)): self.fail('invalid') value = str(data) return value.strip() if self.trim_whitespace else value
We can disable the trimming by declaring trim_whitespace=False in the corresponding serializer. For now, I can only recommend you to remove all trailing whitespace characters until we reach a consensus:
cert = f.read().rstrip()
Please register to edit this issue