Merge commit '3b735dd9330e0989f51a76771c3303031154154e' into 21158-wf-page-list
[arvados.git] / sdk / go / arvados / tls_certs.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import "os"
8
9 // Load root CAs from /etc/arvados/ca-certificates.crt if it exists
10 // and SSL_CERT_FILE does not already specify a different file.
11 func init() {
12         envvar := "SSL_CERT_FILE"
13         certfile := "/etc/arvados/ca-certificates.crt"
14         if os.Getenv(envvar) != "" {
15                 // Caller has already specified SSL_CERT_FILE.
16                 return
17         }
18         if _, err := os.ReadFile(certfile); err != nil {
19                 // Custom cert file is not present/readable.
20                 return
21         }
22         os.Setenv(envvar, certfile)
23 }