Skip to content

Commit

Permalink
Upgrade: forbid upgrading with a key XAPI will reject
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Sep 16, 2024
1 parent 7463132 commit 3e34037
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import re
import shutil

from OpenSSL import crypto

import diskutil
import product
from xcp.version import *
Expand Down Expand Up @@ -217,12 +219,22 @@ def __init__(self, source):
input_data = util.readKeyValueFile(default_storage_conf_path)
self.storage_type = input_data['TYPE']

self.key_size = None
cert_path = os.path.join(primary_fs.mount_point, "etc/xensource/xapi-ssl.pem")
with open(cert_path, "r") as cert_file:
cert_text = cert_file.read()
cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_text)
self.key_size = cert.get_pubkey().bits()
logger.info("ExistingInstallation %s: certificate key size %s", source, self.key_size)

primary_fs.unmount()

def testUpgradeForbidden(self, tool):
utilparts = tool.utilityPartitions()
if tool.partTableType == constants.PARTITION_DOS and utilparts is not None:
raise RuntimeError("Util partition detected on DOS partition type, upgrade forbidden.")
if self.key_size < 2048:
raise RuntimeError("Server certificate is too small, must regenerate on 8.2.1 before upgrade.")

convertTargetStateChanges = []
convertTargetArgs = ['primary-disk', 'target-boot-mode', 'boot-partnum', 'primary-partnum', 'logs-partnum', 'swap-partnum', 'storage-partnum', 'backup-partnum']
Expand Down

0 comments on commit 3e34037

Please sign in to comment.