Skip to content

Commit

Permalink
Feedbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Ashmita Bohara <[email protected]>
  • Loading branch information
Ashmita152 committed Feb 4, 2021
1 parent ef07056 commit 931e764
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ package tlscfg

import (
"crypto/x509"
"fmt"
)

func createCertPool() (*x509.CertPool, error) {
certPool, err := systemCertPool()
if err != nil {
return nil, fmt.Errorf("failed to load SystemCertPool: %w", err)
}
return certPool, nil
func loadSystemCertPool() (*x509.CertPool, error) {
return systemCertPool()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package tlscfg

import (
"crypto/x509"
"fmt"
"syscall"
"unsafe"
)
Expand Down Expand Up @@ -62,17 +61,13 @@ func appendCerts(rootCAs *x509.CertPool) (*x509.CertPool, error) {
return rootCAs, nil
}

func createCertPool() (*x509.CertPool, error) {
func loadSystemCertPool() (*x509.CertPool, error) {
certPool, err := systemCertPool()
if err != nil {
return nil, fmt.Errorf("failed to load SystemCertPool: %w", err)
return nil, err
}
if certPool == nil {
certPool = x509.NewCertPool()
}
certPool, err = appendCerts(certPool)
if err != nil {
return nil, fmt.Errorf("failed to append SystemCertPool: %w", err)
}
return certPool, nil
return appendCerts(certPool)
}
4 changes: 2 additions & 2 deletions pkg/config/tlscfg/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func (p *Options) Config(logger *zap.Logger) (*tls.Config, error) {

func (p Options) loadCertPool() (*x509.CertPool, error) {
if len(p.CAPath) == 0 { // no truststore given, use SystemCertPool
certPool, err := createCertPool()
certPool, err := loadSystemCertPool()
if err != nil {
return nil, fmt.Errorf("failed to create CertPool: %w", err)
return nil, fmt.Errorf("failed to load SystemCertPool: %w", err)
}
return certPool, nil
}
Expand Down

0 comments on commit 931e764

Please sign in to comment.