1 Star 1 Fork 0

Allen / go-scaffold

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
tls.go 516 Bytes
Copy Edit Raw Blame History
Allen authored 2020-07-24 09:39 . init
package server
import (
"crypto/tls"
"io/ioutil"
"go.uber.org/zap"
"golang.org/x/net/http2"
)
// GetTLSConfig for tls
func GetTLSConfig(pemPath, keyPath string) *tls.Config {
// read cert file
crt, _ := ioutil.ReadFile(pemPath)
key, _ := ioutil.ReadFile(keyPath)
pair, err := tls.X509KeyPair(crt, key)
if err != nil {
zap.L().Error("TLS KeyPair err", zap.String("error", err.Error()))
}
return &tls.Config{
Certificates: []tls.Certificate{pair},
NextProtos: []string{http2.NextProtoTLS},
}
}

Comment ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/zakums06/go-scaffold.git
git@gitee.com:zakums06/go-scaffold.git
zakums06
go-scaffold
go-scaffold
v0.1.11

Search