Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Sep 3, 2024
1 parent b346fa4 commit b20cdfa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/tlsutil/tlsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type TLSInfo struct {
// should be left nil. In that case, tls.X509KeyPair will be used.
parseFunc func([]byte, []byte) (tls.Certificate, error)

// AllowedCNs is a list of CNs which must be provided by a client.
AllowedCNs []string
// allowedCNs is a list of CNs which must be provided by a client.
allowedCNs []string
}

// ClientConfig generates a tls.Config object for use by an HTTP client.
Expand Down Expand Up @@ -121,11 +121,11 @@ func (info TLSInfo) baseConfig() (*tls.Config, error) {
cfg.CipherSuites = info.CipherSuites
}

if len(info.AllowedCNs) > 0 {
if len(info.allowedCNs) > 0 {
cfg.VerifyPeerCertificate = func(_ [][]byte, verifiedChains [][]*x509.Certificate) error {
for _, chains := range verifiedChains {
if len(chains) != 0 {
for _, allowedCN := range info.AllowedCNs {
for _, allowedCN := range info.allowedCNs {
if allowedCN == chains[0].Subject.CommonName {
return nil
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (s TLSConfig) ToTLSConfig() (*tls.Config, error) {
CertFile: s.CertPath,
KeyFile: s.KeyPath,
TrustedCAFile: s.CAPath,
AllowedCNs: s.CertAllowedCNs,
allowedCNs: s.CertAllowedCNs,
}

tlsConfig, err := tlsInfo.ClientConfig()
Expand Down

0 comments on commit b20cdfa

Please sign in to comment.