-
Notifications
You must be signed in to change notification settings - Fork 89
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
New module utils openssh.certificate #246
New module utils openssh.certificate #246
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
I'm not really familiar with the OpenSSH file formats, so I mainly looked at the code itself and not whether it's OpenSSH file handling is correct.
I'm wondering a bit whether it's a good idea to do that much parsing here. It might be better to get this (resp. something like this) placed in cryptography, because a) it gets much more thoroughly checked there, and b) by many more eyes than here.
I agree cryptography is the better place for this functionality and I can work on implementing it there, but my guess is that would be a much larger discussion and effort. So my justifications for doing it here first are:
|
That sounds good. In that case, I would remove the writer part of the PR, though, to make sure nobody starts abusing it to create / modify objects in the future :)
In the beginning the module must still work without a dependency on some library that's not widely available on common distros anyway. (It takes years until that's the case.) I think it's still a good long-term goal, and once a cryptography version widely available supports this, I don't see why we can't rely on it. (Hopefully such a version will also support more operations so we can eventually get rid of |
I do need several of the writer's functions to determine public key fingerprints: def public_key_fingerprint(self):
if any([self.e is None, self.n is None]):
return b''
writer = OpensshWriter()
writer.string(_SSH_TYPE_STRINGS['rsa'])
writer.mpint(self.e)
writer.mpint(self.n)
return fingerprint(writer.bytes()) I put a warning in the docstring if that's acceptable. |
Ah, I somehow missed these when grepping.
How about keeping them in that file, but making them internal by renaming |
Done, thanks. |
@Ajpantuso thanks a lot for this contribution! |
SUMMARY
Adding utilities and classes for directly parsing OpenSSH certificates.
ISSUE TYPE
COMPONENT NAME
plugins/module_utils/openssh/certificate.py
ADDITIONAL INFORMATION
Given that
ssh-keygen
does not automate well and the lack of support from common Python libraries implementing SSH I have implemented OpenSSH style certificates in python directly. The original idea was to utilize either cryptography or paramiko, but even the backend utilities of these libraries do not fully implement SSH certificates. Starting from where these libraries left off I introduced a "poor man's" reader/parser and writer for SSH data formats as utilities. The primary interface is exposed incertificate.py
asOpensshCertificate
which can load relevant certificate information for each supported key type as well as the signing key and signature.What was left out:
nonce
generation which can be done viasecrets
, but also key signing which would makecryptography
a dependency)critical_options
orextensions
(Modules should handle this directly)module_utils/openssh