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

Minor fixes to cryptography (x509 and friend) #3520

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

toppk
Copy link
Contributor

@toppk toppk commented Dec 3, 2019

This makes a few corrections that I believe are warranted.

CertificateSigningRequest.public_bytes() takes an encoding parameter in the base class
GeneralName has a value property in the base class
Extensions.get_extension_by_class() takes a Class, not an instance of Extension as argument
Add get_values_for_type() method to several SubjectAlternativeName/IssuerAlternativeName , which also takes a Class, not instance argument class

I'm kinda new to typing, so I believe Type[] is the proper way to specify Class vs instance.

Also, I don't like using Any for value, but I think that's appropriate here.

Fixes #3519

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Looks mostly good, but I have one question below.


class IssuerAlternativeName(ExtensionType):
def __init__(self, general_names: List[GeneralName]) -> None: ...
def __iter__(self) -> Generator[GeneralName, None, None]: ...
def get_values_for_type(self, type: Type[GeneralName]) -> Generator[GeneralName, None, None]: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I can see in the implementation, this (and the one below) just delegate to GeneralNames.get_values_for_type(), which just returns a list of the values from the GeneralNames. So shouldn't the return value be List[Any]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye! I was so focused on the arguments, I didn't scrutinize the return.

It is a list, and you are correct, only another Any will do :/ . It could be Union[Any, OtherName] but that seems superfluous. updated patch (squashed for not polluting the history)

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks! Next time please don't squash as that makes it harder to review the changes. We squash on merge.

@srittau srittau merged commit 86775c8 into python:master Dec 3, 2019
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.

"ExtensionType" has no attribute "get_values_for_type"
2 participants