Skip to content

Commit

Permalink
dnsforward: imp logs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Nov 2, 2022
1 parent 8d71371 commit f4770ab
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/dnsforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func (s *Server) prepareIpsetListSettings() (err error) {
}

// prepareTLS - prepares TLS configuration for the DNS proxy
func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
func (s *Server) prepareTLS(proxyConfig *proxy.Config) (err error) {
if len(s.conf.CertificateChainData) == 0 || len(s.conf.PrivateKeyData) == 0 {
return nil
}
Expand All @@ -485,14 +485,12 @@ func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
proxyConfig.QUICListenAddr,
)

var err error
s.conf.cert, err = tls.X509KeyPair(s.conf.CertificateChainData, s.conf.PrivateKeyData)
if err != nil {
return fmt.Errorf("failed to parse TLS keypair: %w", err)
}

var cert *x509.Certificate
cert, err = x509.ParseCertificate(s.conf.cert.Certificate[0])
cert, err := x509.ParseCertificate(s.conf.cert.Certificate[0])
if err != nil {
return fmt.Errorf("x509.ParseCertificate(): %w", err)
}
Expand All @@ -502,11 +500,11 @@ func (s *Server) prepareTLS(proxyConfig *proxy.Config) error {
if s.conf.StrictSNICheck {
if len(cert.DNSNames) != 0 {
s.conf.dnsNames = cert.DNSNames
log.Debug("dns: using DNS names from certificate's SAN: %v", cert.DNSNames)
log.Debug("dnsforward: using certificate's SAN as DNS names: %v", cert.DNSNames)
sort.Strings(s.conf.dnsNames)
} else {
s.conf.dnsNames = append(s.conf.dnsNames, cert.Subject.CommonName)
log.Debug("dns: using DNS name from certificate's CN: %s", cert.Subject.CommonName)
log.Debug("dnsforward: using certificate's CN as DNS name: %s", cert.Subject.CommonName)
}
}

Expand Down

0 comments on commit f4770ab

Please sign in to comment.