Remove VA.DNSResolver (#7001)

I have confirmed that this config field is not set in any deployment
environment.

Fixes https://github.com/letsencrypt/boulder/issues/6868
This commit is contained in:
Aaron Gable 2023-07-13 17:56:41 -07:00 committed by GitHub
parent 944a865f0d
commit 8d8fd3731b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 53 deletions

View File

@ -105,9 +105,6 @@ type dynamicProvider struct {
// a hostname it will be resolved via the system DNS. If the port is left // a hostname it will be resolved via the system DNS. If the port is left
// unspecified it will default to '53'. If this field is left unspecified // unspecified it will default to '53'. If this field is left unspecified
// the system DNS will be used for resolution of DNS backends. // the system DNS will be used for resolution of DNS backends.
//
// TODO(#6868): Make this field required once 'dnsResolver' is removed from
// the boulder-va JSON config in favor of 'dnsProvider'.
dnsAuthority string dnsAuthority string
// service is the service name to look up SRV records for within the domain. // service is the service name to look up SRV records for within the domain.
// If this field is left unspecified 'dns' will be used as the service name. // If this field is left unspecified 'dns' will be used as the service name.
@ -189,19 +186,15 @@ func StartDynamicProvider(c *cmd.DNSProvider, refresh time.Duration) (*dynamicPr
service = "dns" service = "dns"
} }
// TODO(#6868): Make dnsAuthority required once 'dnsResolver' is removed host, port, err := ParseTarget(c.DNSAuthority, "53")
// from the boulder-va JSON config in favor of 'dnsProvider'. if err != nil {
dnsAuthority := c.DNSAuthority return nil, err
if dnsAuthority != "" { }
host, port, err := ParseTarget(dnsAuthority, "53")
if err != nil { dnsAuthority := net.JoinHostPort(host, port)
return nil, err err = validateServerAddress(dnsAuthority)
} if err != nil {
dnsAuthority = net.JoinHostPort(host, port) return nil, err
err = validateServerAddress(dnsAuthority)
if err != nil {
return nil, err
}
} }
dp := dynamicProvider{ dp := dynamicProvider{
@ -222,7 +215,7 @@ func StartDynamicProvider(c *cmd.DNSProvider, refresh time.Duration) (*dynamicPr
// Update once immediately, so we can know whether that was successful, then // Update once immediately, so we can know whether that was successful, then
// kick off the long-running update goroutine. // kick off the long-running update goroutine.
err := dp.update() err = dp.update()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to start dynamic provider: %w", err) return nil, fmt.Errorf("failed to start dynamic provider: %w", err)
} }
@ -261,17 +254,12 @@ func (dp *dynamicProvider) update() error {
ctx, cancel := context.WithTimeout(context.Background(), dp.refresh/2) ctx, cancel := context.WithTimeout(context.Background(), dp.refresh/2)
defer cancel() defer cancel()
// If dnsAuthority is specified, setup a custom resolver to use it resolver := &net.Resolver{
// otherwise use a default system resolver. PreferGo: true,
resolver := net.DefaultResolver Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
if dp.dnsAuthority != "" { d := &net.Dialer{}
resolver = &net.Resolver{ return d.DialContext(ctx, network, dp.dnsAuthority)
PreferGo: true, },
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := &net.Dialer{}
return d.DialContext(ctx, network, dp.dnsAuthority)
},
}
} }
// RFC 2782 formatted SRV record being queried e.g. "_service._proto.name." // RFC 2782 formatted SRV record being queried e.g. "_service._proto.name."

View File

@ -27,8 +27,7 @@ type Config struct {
// before giving up. May be short-circuited by deadlines. A zero value // before giving up. May be short-circuited by deadlines. A zero value
// will be turned into 1. // will be turned into 1.
DNSTries int DNSTries int
DNSResolver string `validate:"required_without=DNSProvider,excluded_with=DNSProvider,omitempty,hostname|hostname_port"` DNSProvider *cmd.DNSProvider `validate:"required"`
DNSProvider *cmd.DNSProvider `validate:"required_without=DNSResolver,excluded_with=DNSResolver,omitempty"`
DNSTimeout config.Duration `validate:"required"` DNSTimeout config.Duration `validate:"required"`
DNSAllowLoopbackAddresses bool DNSAllowLoopbackAddresses bool
@ -81,22 +80,8 @@ func main() {
} }
clk := cmd.Clock() clk := cmd.Clock()
// TODO(#6868) Remove this once all instances of VA.DNSResolver have been if c.VA.DNSProvider == nil {
// removed from production config files. cmd.Fail("Must specify dnsProvider")
if c.VA.DNSResolver != "" && c.VA.DNSProvider != nil {
cmd.Fail("Cannot specify both 'dnsResolver' and dnsProvider")
}
if c.VA.DNSResolver == "" && c.VA.DNSProvider == nil {
cmd.Fail("Must specify either 'dnsResolver' or dnsProvider")
}
if c.VA.DNSProvider == nil && c.VA.DNSResolver != "" {
c.VA.DNSProvider = &cmd.DNSProvider{
SRVLookup: cmd.ServiceDomain{
Domain: c.VA.DNSResolver,
},
}
} }
var servers bdns.ServerProvider var servers bdns.ServerProvider

View File

@ -525,10 +525,7 @@ type DNSProvider struct {
// a hostname it will be resolved via the system DNS. If the port is left // a hostname it will be resolved via the system DNS. If the port is left
// unspecified it will default to '53'. If this field is left unspecified // unspecified it will default to '53'. If this field is left unspecified
// the system DNS will be used for resolution of DNS backends. // the system DNS will be used for resolution of DNS backends.
// DNSAuthority string `validate:"required,ip|hostname|hostname_port"`
// TODO(#6868): Make this field required once 'dnsResolver' is removed from
// the boulder-va JSON config in favor of 'dnsProvider'.
DNSAuthority string `validate:"omitempty,ip|hostname|hostname_port"`
// SRVLookup contains the service and domain name used to construct a SRV // SRVLookup contains the service and domain name used to construct a SRV
// DNS query to lookup DNS backends. 'Domain' is required. 'Service' is // DNS query to lookup DNS backends. 'Domain' is required. 'Service' is

View File

@ -3,7 +3,13 @@
"userAgent": "boulder-remote-a", "userAgent": "boulder-remote-a",
"debugAddr": ":8011", "debugAddr": ":8011",
"dnsTries": 3, "dnsTries": 3,
"dnsResolver": "service.consul", "dnsProvider": {
"dnsAuthority": "consul.service.consul",
"srvLookup": {
"service": "dns",
"domain": "service.consul"
}
},
"dnsTimeout": "1s", "dnsTimeout": "1s",
"dnsAllowLoopbackAddresses": true, "dnsAllowLoopbackAddresses": true,
"issuerDomain": "happy-hacker-ca.invalid", "issuerDomain": "happy-hacker-ca.invalid",

View File

@ -3,7 +3,13 @@
"userAgent": "boulder-remote-b", "userAgent": "boulder-remote-b",
"debugAddr": ":8012", "debugAddr": ":8012",
"dnsTries": 3, "dnsTries": 3,
"dnsResolver": "service.consul", "dnsProvider": {
"dnsAuthority": "consul.service.consul",
"srvLookup": {
"service": "dns",
"domain": "service.consul"
}
},
"dnsTimeout": "1s", "dnsTimeout": "1s",
"dnsAllowLoopbackAddresses": true, "dnsAllowLoopbackAddresses": true,
"issuerDomain": "happy-hacker-ca.invalid", "issuerDomain": "happy-hacker-ca.invalid",

View File

@ -3,7 +3,13 @@
"userAgent": "boulder", "userAgent": "boulder",
"debugAddr": ":8004", "debugAddr": ":8004",
"dnsTries": 3, "dnsTries": 3,
"dnsResolver": "service.consul", "dnsProvider": {
"dnsAuthority": "consul.service.consul",
"srvLookup": {
"service": "dns",
"domain": "service.consul"
}
},
"dnsTimeout": "1s", "dnsTimeout": "1s",
"dnsAllowLoopbackAddresses": true, "dnsAllowLoopbackAddresses": true,
"issuerDomain": "happy-hacker-ca.invalid", "issuerDomain": "happy-hacker-ca.invalid",