Skip to content

Commit

Permalink
Made cert loading only occur on onprem @yashsinghcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Aug 20, 2024
1 parent fca85d9 commit bcbadec
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -23646,35 +23646,37 @@ func GetExternalClient(baseUrl string) *http.Client {
InsecureSkipVerify: skipSSLVerify,
}

rootCAs, _ := x509.SystemCertPool()
if rootCAs == nil {
rootCAs = x509.NewCertPool()
}
if project.Environment != "cloud" {
rootCAs, _ := x509.SystemCertPool()
if rootCAs == nil {
rootCAs = x509.NewCertPool()
}

certDir := "/certs/"
certDir := "/certs/"

if os.Getenv("SHUFFLE_CERT_DIR") != "" {
certDir = os.Getenv("SHUFFLE_CERT_DIR")
}
if os.Getenv("SHUFFLE_CERT_DIR") != "" {
certDir = os.Getenv("SHUFFLE_CERT_DIR")
}

log.Printf("[INFO] Reading self signed certificates from %s dir", certDir)
log.Printf("[INFO] Reading self signed certificates from %s dir", certDir)

files, err := os.ReadDir(certDir)
if err == nil && os.Getenv("SHUFFLE_CERT_DIR") != "" {
for _, file := range files {
if !file.IsDir() {
certPath := filepath.Join(certDir, file.Name())
caCert, err := os.ReadFile(certPath)
if err != nil {
log.Printf("[ERROR] Error reading the certificate %s: %s", file.Name(), err)
} else {
if ok := rootCAs.AppendCertsFromPEM(caCert); ok {
log.Printf("[INFO] Successfully appended certificate: %s", file.Name())
files, err := os.ReadDir(certDir)
if err == nil && os.Getenv("SHUFFLE_CERT_DIR") != "" {
for _, file := range files {
if !file.IsDir() {
certPath := filepath.Join(certDir, file.Name())
caCert, err := os.ReadFile(certPath)
if err != nil {
log.Printf("[ERROR] Error reading the certificate %s: %s", file.Name(), err)
} else {
if ok := rootCAs.AppendCertsFromPEM(caCert); ok {
log.Printf("[INFO] Successfully appended certificate: %s", file.Name())
}
}
}
}
transport.TLSClientConfig = &tls.Config{RootCAs: rootCAs}
}
transport.TLSClientConfig = &tls.Config{RootCAs: rootCAs}
}


Expand Down

0 comments on commit bcbadec

Please sign in to comment.