diff options
author | Devaev Maxim <[email protected]> | 2020-04-23 11:17:22 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-04-23 11:17:31 +0300 |
commit | 75669466cf6b68fbe209a6d2232aec6d49a51044 (patch) | |
tree | 74bdd3064eb76e0d5b6cabd2c6df07bc425e8ea5 /kvmd/validators/net.py | |
parent | 820ef178710d8442e30c5b23d0ac0cb90be5150c (diff) |
vnc: anon tls encryption
Diffstat (limited to 'kvmd/validators/net.py')
-rw-r--r-- | kvmd/validators/net.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kvmd/validators/net.py b/kvmd/validators/net.py index 247122cd..7862c391 100644 --- a/kvmd/validators/net.py +++ b/kvmd/validators/net.py @@ -21,11 +21,13 @@ import ipaddress +import ssl from typing import List from typing import Callable from typing import Any +from . import ValidatorError from . import check_re_match from . import check_any @@ -75,3 +77,13 @@ def valid_port(arg: Any) -> int: def valid_mac(arg: Any) -> str: pattern = ":".join([r"[0-9a-fA-F]{2}"] * 6) return check_re_match(arg, "MAC address", pattern).lower() + + +def valid_ssl_ciphers(arg: Any) -> str: + name = "SSL ciphers" + arg = valid_stripped_string_not_empty(arg, name) + try: + ssl.SSLContext().set_ciphers(arg) + except Exception as err: + raise ValidatorError(f"The argument {arg!r} is not a valid {name}: {str(err)}") + return arg |