"type": "boolean",
"description": "Enable/disable DNSSEC.",
"default": true
+ },
+ "insecure": {
+ "type": "boolean",
+ "description": "Allow insecure TLS configuration.",
+ "default": false
}
},
"default": {
"authoritative": false,
- "dnssec": true
+ "dnssec": true,
+ "insecure": false
}
}
}
def _validate(self) -> None:
if self.pin_sha256 and (self.hostname or self.ca_file):
- raise ValueError("'pin-sha256' cannot be configurad together with 'hostname' or 'ca-file'")
+ raise ValueError("'pin-sha256' cannot be configured together with 'hostname' or 'ca-file'")
class ForwardOptionsSchema(ConfigSchema):
---
authoritative: The forwarding target is an authoritative server.
dnssec: Enable/disable DNSSEC.
+ insecure: Allow insecure TLS configuration.
+
"""
authoritative: bool = False
dnssec: bool = True
+ insecure: bool = False
class ForwardSchema(ConfigSchema):
if self.options.authoritative and is_transport_tls(self.servers):
raise ValueError("Forwarding to authoritative servers using TLS protocol is not supported.")
+
+ if not self.options.insecure:
+ for server in self.servers:
+ if (
+ isinstance(server, ForwardServerSchema)
+ and server.transport == "tls"
+ and not (server.pin_sha256 or server.hostname or server.ca_file)
+ ):
+ raise ValueError(
+ "no way to authenticate server (hostname, ca-file or pin-sha256) and 'insecure' is not set"
+ )
{dnssec={{ boolean(options.dnssec) }},auth={{ boolean(options.authoritative) }}}
{%- endmacro %}
-{% macro forward_server(server) -%}
+{% macro forward_server(server, options) -%}
{%- if server.address is defined and server.address-%}
{%- for addr in server.address -%}
{'{{ addr }}',
{%- else -%}
tls=false,
{%- endif -%}
+{%- if options.insecure -%}
+insecure=true,
+{%- else -%}
+insecure=false,
+{%- endif -%}
{%- if server.hostname -%}
hostname='{{ server.hostname }}',
{%- endif -%}
{%- endif -%}
{%- endmacro %}
-{% macro forward_servers(servers) -%}
+{% macro forward_servers(servers, options) -%}
{
{%- for server in servers -%}
-{{ forward_server(server) }}
+{{ forward_server(server, options) }}
{%- endfor -%}
}
{%- endmacro %}
{% macro policy_rule_forward_add(subtree,options,servers) -%}
-policy.rule_forward_add('{{ subtree }}',{{ forward_options(options) }},{{ forward_servers(servers) }})
+policy.rule_forward_add('{{ subtree }}',{{ forward_options(options) }},{{ forward_servers(servers, options) }})
{%- endmacro %}
},
}
)
- result = "policy.rule_forward_add('.',{dnssec=true,auth=false},{{'2001:148f:fffe::1',tls=false,hostname='odvr.nic.cz',},{'185.43.135.1',tls=false,hostname='odvr.nic.cz',},})"
+ result = "policy.rule_forward_add('.',{dnssec=true,auth=false},{{'2001:148f:fffe::1',tls=false,insecure=false,hostname='odvr.nic.cz',},{'185.43.135.1',tls=false,insecure=false,hostname='odvr.nic.cz',},})"
tmpl = template_from_str(tmpl_str)
assert tmpl.render(rule=rule) == result