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

pass or collect comments for ssh private keys #9019

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

gzm55
Copy link

@gzm55 gzm55 commented Jun 3, 2023

close #8980

@gzm55
Copy link
Author

gzm55 commented Jun 9, 2023

@alex could you plz review this pr?

@alex
Copy link
Member

alex commented Jun 9, 2023 via email

Comment on lines +620 to +622
comment_collector: typing.Union[
typing.Callable[[bytes], None], None
] = None,
Copy link
Member

Choose a reason for hiding this comment

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

This API is pretty out of step with anything we have elsewhere. Are there any ways we can avoid a callback like this?

Copy link
Author

Choose a reason for hiding this comment

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

another way is to save the comments in a runtime attribute of the loaded private key

Comment on lines +765 to +768
if hasattr(encryption_algorithm, "_comment"):
_comment_attr = getattr(encryption_algorithm, "_comment")
if isinstance(_comment_attr, bytes):
comment = _comment_attr
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what this is for, or where the comment attribute is supposed to come from?

Copy link
Author

Choose a reason for hiding this comment

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

ok, we can omit checking isinstance of bytes

@reaperhulk
Copy link
Member

IMO, this signature is too foreign to the rest of our API surface. Another (possibly bad) idea: should we have a separate loader load_ssh_key_with_comment that is documented as returning comment bytes (e.g. Tuple[PrivateKeyType, bytes])?

@gzm55
Copy link
Author

gzm55 commented Jun 18, 2023

@reaperhulk another api is ok, but most codes of the new api have to be copied directly from the original one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

add support custom comments when formatting openssh private keys
3 participants