Skip to content

Conversation

@ydirson
Copy link
Contributor

@ydirson ydirson commented Sep 16, 2024

XAPI now rejects the default keysize of 7.x era, which must be regenerated before upgrading to 8.3. Let the installer refuse to initiate a situation where a Rolling Pool Upgrade would be unable to proceed, with not-yet-updated slaves holding the running VMs getting refused connection to the updated part of the pool.

This now stops the upgrade with the following screen, but after letting the user give consent for launching the upgrade:

cert-too-small

upgrade.py Outdated
if tool.partTableType == constants.PARTITION_DOS:
raise RuntimeError("Upgrade from a DOS partition type is not supported.")
if self.key_size < 2048:
raise RuntimeError("Server certificate is too small, must regenerate on 8.2.1 before upgrade.")
Copy link
Contributor

@alexbrett alexbrett Sep 16, 2024

Choose a reason for hiding this comment

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

I'm nervous about stating a specific version number, perhaps better to have this as e.g. "Current server certificate is too small (%d bits), please regenerate with at least 2048 bits" % (self.key_size,)?

(It may also be a good idea to encode the 2048 as a MIN_KEY_SIZE constant in case this needs to change in the future)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted in last push

@ydirson ydirson force-pushed the for-xs/certificate-keysize-protection branch 3 times, most recently from 1871e0a to 8ab5b8d Compare September 16, 2024 16:13
@ydirson ydirson requested a review from alexbrett September 16, 2024 16:14
@ydirson
Copy link
Contributor Author

ydirson commented Mar 17, 2025

any news on this?

@freddy77
Copy link
Contributor

What if the certificate is not using RSA ? Other algorithms require smaller key sizes.

@stormi
Copy link
Contributor

stormi commented Mar 25, 2025

What if the certificate is not using RSA ? Other algorithms require smaller key sizes.

Currently, XAPI doesn't support anything but RSA for this certificate.

import re
import shutil

from OpenSSL import crypto
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need an additional dependency in order to use OpenSSL module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is right. Is it too big? I'm not sure we have many alternatives to choose from.

@psafont
Copy link
Contributor

psafont commented Mar 26, 2025

Xapi currently enforces not only the key size, but the algorithm as well. So to be extra safe I recommend adding a check that the key must be an RSA one. (and change the message accordingly)

https://github.com/xapi-project/xen-api/blob/afe37ec7cc577755c4a4880fa133848d326e0cc3/ocaml/gencert/lib.ml#L21-L36

@ydirson ydirson force-pushed the for-xs/certificate-keysize-protection branch from 8ab5b8d to fb9e0a6 Compare April 3, 2025 14:28
@ydirson
Copy link
Contributor Author

ydirson commented Apr 3, 2025

Added the check for RSA type, and made a few improvements

@ydirson ydirson requested a review from freddy77 April 3, 2025 14:39
XAPI now rejects the default keysize of 7.x era, which must be
regenerated before upgrading to 8.3.  Let the installer refuse to
initiate a situation where a Rolling Pool Upgrade would be unable to
proceed, with not-yet-updated slaves holding the running VMs getting
refused connection to the updated part of the pool.

To be extra-safe, add a check that the key is indeed a RSA one as
that's all current XAPI supports, this will make sure this code gets
updated when XAPI starts supporting other key types.

Signed-off-by: Yann Dirson <yann.dirson@vates.tech>
@ydirson ydirson force-pushed the for-xs/certificate-keysize-protection branch from fb9e0a6 to 7542c28 Compare April 3, 2025 14:41
@ydirson
Copy link
Contributor Author

ydirson commented Apr 3, 2025

and added back the "before upgrade" that slept away during the message reformulation

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.

5 participants