Add checkbox to enable SSL connection for SPICE

If in OpenNebula not enabled TLS for SPICE protocol, when
cannot connect to OpenNebula with generated virt-viewer connection
config file, because "secure-channel" options successfully work
over TLS only.
This changes allow enable or disable TLS on UDS site.
This commit is contained in:
Alexander Burmatov 2023-01-27 18:21:09 +03:00
parent 879ae4b74a
commit 6240c4cbff
3 changed files with 11 additions and 1 deletions

View File

@ -65,6 +65,7 @@ class RemoteViewerFile:
usb_auto_share: bool = True usb_auto_share: bool = True
new_usb_auto_share: bool = False new_usb_auto_share: bool = False
delete_file: bool = True delete_file: bool = True
ssl_connection: bool = False
def __init__( def __init__(
self, self,
@ -101,6 +102,7 @@ class RemoteViewerFile:
delete_file = '01'[self.delete_file] delete_file = '01'[self.delete_file]
usb_auto_share = '01'[self.usb_auto_share] usb_auto_share = '01'[self.usb_auto_share]
new_usb_auto_share = '01'[self.new_usb_auto_share] new_usb_auto_share = '01'[self.new_usb_auto_share]
ssl_connection = '01'[self.ssl_connection]
ca = self.ca.strip().replace( ca = self.ca.strip().replace(
'\n', '\\n' '\n', '\\n'
@ -121,6 +123,6 @@ class RemoteViewerFile:
host_subject=self.host_subject if tls_port != '-1' else '', host_subject=self.host_subject if tls_port != '-1' else '',
ca=ca if tls_port != '-1' else '', ca=ca if tls_port != '-1' else '',
secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard' secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard'
if tls_port != '-1' if ssl_connection and tls_port != '-1'
else '', else '',
) )

View File

@ -64,6 +64,7 @@ class SPICETransport(BaseSpiceTransport):
usbShare = BaseSpiceTransport.usbShare usbShare = BaseSpiceTransport.usbShare
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
smartCardRedirect = BaseSpiceTransport.smartCardRedirect smartCardRedirect = BaseSpiceTransport.smartCardRedirect
sslConnection = BaseSpiceTransport.SSLConnection
def getUDSTransportScript( def getUDSTransportScript(
self, self,
@ -98,6 +99,7 @@ class SPICETransport(BaseSpiceTransport):
r.usb_auto_share = self.usbShare.isTrue() r.usb_auto_share = self.usbShare.isTrue()
r.new_usb_auto_share = self.autoNewUsbShare.isTrue() r.new_usb_auto_share = self.autoNewUsbShare.isTrue()
r.smartcard = self.smartCardRedirect.isTrue() r.smartcard = self.smartCardRedirect.isTrue()
r.ssl = self.sslConnection.isTrue()
osName = { osName = {
OsDetector.KnownOS.Windows: 'windows', OsDetector.KnownOS.Windows: 'windows',

View File

@ -113,6 +113,12 @@ class BaseSpiceTransport(transports.Transport):
defvalue=gui.FALSE, defvalue=gui.FALSE,
tab=gui.ADVANCED_TAB, tab=gui.ADVANCED_TAB,
) )
SSLConnection = gui.CheckBoxField(
order=9,
label=_('SSL Connection'),
tooltip=_('If checked, SPICE protocol will required SSL connection.'),
defvalue=gui.FALSE,
)
def isAvailableFor(self, userService: 'models.UserService', ip: str) -> bool: def isAvailableFor(self, userService: 'models.UserService', ip: str) -> bool:
""" """