forked from quic-go/quic-go
remove DER certificates and use PEMs instead
This commit is contained in:
BIN
example/cert.der
BIN
example/cert.der
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
example/key.der
BIN
example/key.der
Binary file not shown.
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -85,10 +84,13 @@ func main() {
|
||||
tlsConfig = testdata.GetTLSConfig()
|
||||
} else {
|
||||
var err error
|
||||
tlsConfig, err = tlsConfigFromCertpath(*certPath)
|
||||
cert, err := tls.LoadX509KeyPair(*certPath+"/fullchain.pem", *certPath+"/privkey.pem")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tlsConfig = &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
}
|
||||
}
|
||||
|
||||
http.Handle("/", http.FileServer(http.Dir(*www)))
|
||||
@@ -118,24 +120,3 @@ func main() {
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func tlsConfigFromCertpath(certpath string) (*tls.Config, error) {
|
||||
keyDer, err := ioutil.ReadFile(certpath + "/key.der")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
certDer, err := ioutil.ReadFile(certpath + "/cert.der")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key, err := x509.ParsePKCS1PrivateKey(keyDer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &tls.Config{
|
||||
Certificates: []tls.Certificate{{
|
||||
Certificate: [][]byte{certDer},
|
||||
PrivateKey: key,
|
||||
}},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user