Skip to content

Conversation

@sigmavirus24
Copy link

pyOpenSSL is already a dependency and pyOpenSSL uses cryptography.
This also reduces the complexity of the code significantly in several
places (and removes the need to directly manipulate asn1). A future
PR could remove pyOpenSSL entirely as all the cert behavior is supported
directly by cryptography.

@prometheanfire
Copy link

👍 doubleplusgood

"""
for tmp_cert_str in cert_chain_str_list:
valid, message = self.verify(tmp_cert_str, cert_str)
print("validated")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks strange, leftover from testing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks!

assert not OpenSSLWrapper().certificate_not_valid_yet(cert)
return True
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_str)
assert cert.has_expired() == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertion in production code might be optimized out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm simply replacing an existing assertion. I expect @rohe already knows that about this code.

cert_algorithm = cert.get_signature_algorithm()
if six.PY3:
cert_algorithm = cert_algorithm.decode('ascii')
cert_str = cert_str.encode('ascii')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the certificate contains umlauts e.g. "ä"? Are they encoded in a special format?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cert_str is a PEM formatted string here, which is guaranteed to be ascii. The requirement for this is because load_pem_x509_certificate takes bytes, not text.

pyOpenSSL is already a dependency and pyOpenSSL uses cryptography.
This also reduces the complexity of the code significantly in several
places (and removes the need to directly manipulate asn1). A future
PR could remove pyOpenSSL entirely as all the cert behavior is supported
directly by cryptography.
@lhh
Copy link

lhh commented Jan 23, 2017

Not that my vote has any weight here, but 👍

@rohe rohe merged commit a0c510a into IdentityPython:master Jan 24, 2017
@sigmavirus24 sigmavirus24 deleted the move-to-cryptography branch January 24, 2017 18:57
@sigmavirus24
Copy link
Author

sigmavirus24 commented Jan 24, 2017 via email

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

Successfully merging this pull request may close these issues.

8 participants