@@ -11,24 +11,20 @@ class ForwardServerSchema(ConfigSchema):
11
11
---
12
12
address: IP address(es) of a forward server.
13
13
transport: Transport protocol for a forward server.
14
- insecure: Allow insecure TLS configuration.
15
14
pin_sha256: Hash of accepted CA certificate.
16
15
hostname: Hostname of the Forward server.
17
16
ca_file: Path to CA certificate file.
18
17
"""
19
18
20
19
address : ListOrItem [IPAddressOptionalPort ]
21
20
transport : Optional [Literal ["tls" ]] = None
22
- insecure : bool = False
23
21
pin_sha256 : Optional [ListOrItem [PinSha256 ]] = None
24
22
hostname : Optional [DomainName ] = None
25
23
ca_file : Optional [ReadableFile ] = None
26
24
27
25
def _validate (self ) -> None :
28
26
if self .pin_sha256 and (self .hostname or self .ca_file ):
29
- raise ValueError ("'pin-sha256' cannot be configurad together with 'hostname' or 'ca-file'" )
30
- if not self .insecure and not (self .pin_sha256 or self .hostname or self .ca_file ):
31
- raise ValueError ("no way to authenticate and 'insecure' not set" )
27
+ raise ValueError ("'pin-sha256' cannot be configured together with 'hostname' or 'ca-file'" )
32
28
33
29
34
30
class ForwardOptionsSchema (ConfigSchema ):
@@ -38,10 +34,13 @@ class ForwardOptionsSchema(ConfigSchema):
38
34
---
39
35
authoritative: The forwarding target is an authoritative server.
40
36
dnssec: Enable/disable DNSSEC.
37
+ insecure: Allow insecure TLS configuration.
38
+
41
39
"""
42
40
43
41
authoritative : bool = False
44
42
dnssec : bool = True
43
+ insecure : bool = False
45
44
46
45
47
46
class ForwardSchema (ConfigSchema ):
@@ -78,3 +77,14 @@ def is_transport_tls(servers: List[Any]) -> bool:
78
77
79
78
if self .options .authoritative and is_transport_tls (self .servers ):
80
79
raise ValueError ("Forwarding to authoritative servers using TLS protocol is not supported." )
80
+
81
+ if not self .options .insecure :
82
+ for server in self .servers :
83
+ if (
84
+ isinstance (server , ForwardServerSchema )
85
+ and server .transport == "tls"
86
+ and not (server .pin_sha256 or server .hostname or server .ca_file )
87
+ ):
88
+ raise ValueError (
89
+ "no way to authenticate server (hostname, ca-file or pin-sha256) and 'insecure' is not set"
90
+ )
0 commit comments