Http 服务加载多个ssl证书

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
cfg := &tls.Config{}

cert, err := tls.LoadX509KeyPair("cert_one.pem", "key_one.pem")
if err != nil {
    log.Fatal(err)
}

cfg.Certificates = append(cfg.Certificates, cert)
// keep adding remaining certs to cfg.Certificates

server := http.Server{
    Addr:      ":443",
    // Handler:   myHandler,
    TLSConfig: cfg,
}

server.ListenAndServeTLS("", "")

http.ListenAndServeTLS with multiple certificates