Repository navigation
python-common/cryptotools: reimplement on top of cryptography - #69510
Conversation
|
@phlogistonjohn hi John, this is a follow up of #69446. it's much less urgent that it, but it should help us to address similar issues which might happen in future, due to the usage of deprecation-then-removed APIs in pyOpenSSL. |
7ca180d to
0d44f4e
Compare
the last change dropped X509Req, but InternalCryptoCaller still uses pyOpenSSL, which keeps deprecating and removing its OpenSSL.crypto and OpenSSL.SSL APIs. pyOpenSSL's own README [1] says: If you are using pyOpenSSL for anything other than making a TLS connection you should move to cryptography and drop your pyOpenSSL dependency. none of this module makes a TLS connection, and we already depend on cryptography and use it in cephadm/ssl_cert_utils.py. so reimplement the caller with cryptography: - create_private_key(): rsa.generate_private_key() dumped as PKCS8 PEM, the same format pyOpenSSL produced. - create_self_signed_cert(): x509.CertificateBuilder, with the dname fields mapped to their NameOIDs. - _load_cert() and get_cert_issuer_info(): load_pem_x509_certificate() and cert.issuer. - certificate_days_to_expire(): cert.not_valid_after. - verify_tls(): compare the cert's and the key's public keys instead of loading them into an SSL.Context. password_hash() and verify_password() already used bcrypt, so they are left as is. the output formats and error behavior are unchanged, hence the existing tls tests pass without changes. [1] https://github.com/pyca/pyopenssl/blob/main/README.rst Signed-off-by: Kefu Chai <[email protected]>
0d44f4e to
d814088
Compare
phlogistonjohn
left a comment
There was a problem hiding this comment.
Generally LGTM. We'll definitely want a robust teuthology run for this though!
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
This commit adds a new field to CephCluster (`.spec.dashboard.sslCertificateRef`) that can refer to a Kubernetes `Secret` of type `kubernetes.io/tls` (like those provisioned via cert-manager) that will be used by the Ceph Dashboard. It validates the cert public/private keys match, that they are RSA (presently a requirement for the Ceph dashboard, see https://docs.ceph.com/en/latest/mgr/dashboard/#ssl-tls-support, although this may change in the future with ceph/ceph#69510, there is an issue tracking this: https://tracker.ceph.com/issues/73324), and will watch the secret as part of the controller to ensure it gets reconciled when the secret changes. Also adds appropriate release notes. Signed-off-by: Ben Dronen <[email protected]>
|
@tchaikov I created the issue https://tracker.ceph.com/issues/80414 to track the change and I'll be backporting it to umbrella. |
|
@rkachach Redouane, actually i was reading your ping the day before yesterday but was in the middle of something else, and thought i could do it later.. thanks for creating the issue and the backport! |
No worries @tchaikov, thanks for the fix. Since I needed the commit to pass the |
the last change dropped X509Req, but InternalCryptoCaller still uses pyOpenSSL, which keeps deprecating and removing its OpenSSL.crypto and OpenSSL.SSL APIs. pyOpenSSL's own README [1] says:
none of this module makes a TLS connection, and we already depend on cryptography and use it in
cephadm/ssl_cert_utils.py.so reimplement the caller with cryptography:
create_private_key(): rsa.generate_private_key() dumped as PKCS8 PEM, the same format pyOpenSSL produced.create_self_signed_cert(): x509.CertificateBuilder, with the dname fields mapped to their NameOIDs._load_cert() and get_cert_issuer_info(): load_pem_x509_certificate() and cert.issuer.certificate_days_to_expire(): cert.not_valid_after.verify_tls(): compare the cert's and the key's public keys instead of loading them into anSSL.Context.password_hash()andverify_password()already used bcrypt, so they are left as is. the output formats and error behavior are unchanged, hence the existing tls tests pass without changes.[1] https://github.com/pyca/pyopenssl/blob/main/README.rst
POST-EDIT:
Fixes: https://tracker.ceph.com/issues/80414
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.