diff --git a/example/main.go b/example/main.go index cd476e44..014003f6 100644 --- a/example/main.go +++ b/example/main.go @@ -144,6 +144,8 @@ func main() { flag.Var(&bs, "bind", "bind to") www := flag.String("www", "", "www data") tcp := flag.Bool("tcp", false, "also listen on TCP") + key := flag.String("key", "", "TLS key (requires -cert option)") + cert := flag.String("cert", "", "TLS certificate (requires -key option)") enableQlog := flag.Bool("qlog", false, "output a qlog (in the same directory)") flag.Parse() @@ -176,12 +178,18 @@ func main() { var wg sync.WaitGroup wg.Add(len(bs)) + var certFile, keyFile string + if *key != "" && *cert != "" { + keyFile = *key + certFile = *cert + } else { + certFile, keyFile = testdata.GetCertificatePaths() + } for _, b := range bs { bCap := b go func() { var err error if *tcp { - certFile, keyFile := testdata.GetCertificatePaths() err = http3.ListenAndServe(bCap, certFile, keyFile, handler) } else { server := http3.Server{ @@ -189,7 +197,7 @@ func main() { Addr: bCap, QuicConfig: quicConf, } - err = server.ListenAndServeTLS(testdata.GetCertificatePaths()) + err = server.ListenAndServeTLS(certFile, keyFile) } if err != nil { fmt.Println(err)