refactor(azure): Extract SSH key cert handling to new certs module#6561
refactor(azure): Extract SSH key cert handling to new certs module#6561peytonr18 wants to merge 4 commits intocanonical:mainfrom
Conversation
…ete openssl and ssh-keygen functionality
45f78e2 to
f4e3af9
Compare
…sity Added extract_x509_certificate() to validate certificates in bundles, integrated validation into parse_certificates(), and toned down debug logs to avoid sounding like failures.
f4e3af9 to
90eb57b
Compare
|
The following was discussed offline, and these changes are reflected in the most recent commit: Re: The current parse_certificates() really extracts the x509 certificate from whatever bundle it might be in, I'm inclined to think the safest bet is to essentially extract this into another interface: |
|
It looks like this is waiting for updates per the latest review, so I'll hold off on reviewing it for now. |
Fold the regex-based certificate parsing into cloudinit.sources.azure.certs so helpers no longer reimplement it, and wire OpenSSLManager.parse_certificates to loop over the helper. Added a regression test that confirms CRLF-mixed bundles still yield every fingerprint + key pair.
4ad543b to
e401a2e
Compare
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
|
We are making changes on our end before reviewing this one to make sure our testing infrastructure is prepared to handle this change. Once those are finished, I'll reopen this PR for review. |
|
@blackboxsw Looking to reopen this PR now that we have completed the basework, so I can continue working on it. Thanks! |
Proposed Commit Message
Additional Context
Purpose:
Refactors x509 certificate and SSH key handling logic from
OpenSSLManagerandDataSourceAzureinto a dedicated module (cloudinit/sources/azure/certs.py).Changes:
cloudinit/sources/azure/certs.pywith three functions:is_openssh_formatted()- Validates OpenSSH format keysis_x509_certificate()- Validates x509 certificates using opensslconvert_x509_to_openssh()- Converts x509 certs to OpenSSH keyscloudinit/sources/helpers/azure.py-->_get_ssh_key_from_cert()now uses new modulecloudinit/sources/DataSourceAzure.py-->_key_is_openssh_formatted()now uses new moduleTest Coverage:
opensslfor x509 validation & withopenssl+ssh-keygenfor cert conversionMerge type