Exemple #1
0
def _validate_load_certificate(value):
    value = cv.file_(value)
    try:
        contents = read_relative_config_path(value)
        return wrapped_load_pem_x509_certificate(contents)
    except ValueError as err:
        raise cv.Invalid(f"Invalid certificate: {err}")
Exemple #2
0
def validate_truetype_file(value):
    if value.endswith('.zip'):  # for Google Fonts downloads
        raise vol.Invalid(u"Please unzip the font archive '{}' first and then use the .ttf files "
                          u"inside.".format(value))
    if not value.endswith('.ttf'):
        raise vol.Invalid(u"Only truetype (.ttf) files are supported. Please make sure you're "
                          u"using the correct format or rename the extension to .ttf")
    return cv.file_(value)
Exemple #3
0
def validate_truetype_file(value):
    if value.endswith(".zip"):  # for Google Fonts downloads
        raise cv.Invalid(
            f"Please unzip the font archive '{value}' first and then use the .ttf files inside."
        )
    if not value.endswith(".ttf"):
        raise cv.Invalid(
            "Only truetype (.ttf) files are supported. Please make sure you're "
            "using the correct format or rename the extension to .ttf")
    return cv.file_(value)
Exemple #4
0
def _validate_load_private_key(key, cert_pw):
    key = cv.file_(key)
    try:
        contents = read_relative_config_path(key)
        return wrapped_load_pem_private_key(contents, cert_pw)
    except ValueError as e:
        raise cv.Invalid(
            f"There was an error with the EAP 'password:'******'key' {e}"
        )
    except TypeError as e:
        raise cv.Invalid(f"There was an error with the EAP 'key:' provided: {e}")
def valid_include(value):
    try:
        return cv.directory(value)
    except cv.Invalid:
        pass
    value = cv.file_(value)
    _, ext = os.path.splitext(value)
    if ext not in VALID_INCLUDE_EXTS:
        raise cv.Invalid("Include has invalid file extension {} - valid extensions are {}"
                         "".format(ext, ', '.join(VALID_INCLUDE_EXTS)))
    return value