about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.16.patch
blob: f4bc16e5b8cbb26f03fda5a7a4cada57862418e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/src/crypto/x509/root.go b/src/crypto/x509/root.go
index ac92915128..fb1d70c735 100644
--- a/src/crypto/x509/root.go
+++ b/src/crypto/x509/root.go
@@ -6,7 +6,11 @@ package x509
 
 //go:generate go run root_ios_gen.go -version 55161.140.3
 
-import "sync"
+import (
+	"io/ioutil"
+	"os"
+	"sync"
+)
 
 var (
 	once           sync.Once
@@ -20,6 +24,16 @@ func systemRootsPool() *CertPool {
 }
 
 func initSystemRoots() {
+	if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
+		data, err := ioutil.ReadFile(file)
+		if err == nil {
+			roots := NewCertPool()
+			roots.AppendCertsFromPEM(data)
+			systemRoots = roots
+			return
+		}
+	}
+
 	systemRoots, systemRootsErr = loadSystemRoots()
 	if systemRootsErr != nil {
 		systemRoots = nil