@@ -8,7 +8,6 @@ package irc
88import (
99 "bytes"
1010 "crypto/tls"
11- "crypto/x509"
1211 "errors"
1312 "fmt"
1413 "io"
@@ -942,15 +941,15 @@ func loadTlsConfig(config listenerConfigBlock) (tlsConfig *tls.Config, err error
942941 if len (config .TLSCertificates ) != 0 {
943942 // SNI configuration with multiple certificates
944943 for _ , certPairConf := range config .TLSCertificates {
945- cert , err := loadCertWithLeaf (certPairConf .Cert , certPairConf .Key )
944+ cert , err := tls . LoadX509KeyPair (certPairConf .Cert , certPairConf .Key )
946945 if err != nil {
947946 return nil , err
948947 }
949948 certificates = append (certificates , cert )
950949 }
951950 } else if config .TLS .Cert != "" {
952951 // normal configuration with one certificate
953- cert , err := loadCertWithLeaf (config .TLS .Cert , config .TLS .Key )
952+ cert , err := tls . LoadX509KeyPair (config .TLS .Cert , config .TLS .Key )
954953 if err != nil {
955954 return nil , err
956955 }
@@ -993,20 +992,6 @@ func tlsMinVersionFromString(version string) uint16 {
993992 }
994993}
995994
996- func loadCertWithLeaf (certFile , keyFile string ) (cert tls.Certificate , err error ) {
997- // LoadX509KeyPair: "On successful return, Certificate.Leaf will be nil because
998- // the parsed form of the certificate is not retained." tls.Config:
999- // "Note: if there are multiple Certificates, and they don't have the
1000- // optional field Leaf set, certificate selection will incur a significant
1001- // per-handshake performance cost."
1002- cert , err = tls .LoadX509KeyPair (certFile , keyFile )
1003- if err != nil {
1004- return
1005- }
1006- cert .Leaf , err = x509 .ParseCertificate (cert .Certificate [0 ])
1007- return
1008- }
1009-
1010995// prepareListeners populates Config.Server.trueListeners
1011996func (conf * Config ) prepareListeners () (err error ) {
1012997 if len (conf .Server .Listeners ) == 0 {
@@ -1079,7 +1064,7 @@ func (config *Config) processAPI() (err error) {
10791064
10801065 var tlsConfig * tls.Config
10811066 if config .API .TLS .Cert != "" {
1082- cert , err := loadCertWithLeaf (config .API .TLS .Cert , config .API .TLS .Key )
1067+ cert , err := tls . LoadX509KeyPair (config .API .TLS .Cert , config .API .TLS .Key )
10831068 if err != nil {
10841069 return err
10851070 }
0 commit comments