11 "github.com/mjl-/mox/dane"
12 "github.com/mjl-/mox/dns"
16 ctx := context.Background()
17 resolver := dns.StrictResolver{}
18 usages := []adns.TLSAUsage{adns.TLSAUsageDANETA, adns.TLSAUsageDANEEE}
19 pkixRoots, err := x509.SystemCertPool()
21 log.Fatalf("system pkix roots: %v", err)
24 // Connect to SMTP server, use STARTTLS, and verify TLS certificate with DANE.
25 conn, verifiedRecord, err := dane.Dial(ctx, slog.Default(), resolver, "tcp", "mx.example.com", usages, pkixRoots)
27 log.Fatalf("dial: %v", err)
31 log.Printf("connected, conn %v, verified record %s", conn, verifiedRecord)