about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.12.1.patch
blob: aa3116d76c125674644589f074b95fe03bd6a7c7 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff -Naur a/src/crypto/x509/root_cgo_darwin.go b/src/crypto/x509/root_cgo_darwin.go
--- a/src/crypto/x509/root_cgo_darwin.go	2019-03-15 11:33:55.920232337 -0700
+++ b/src/crypto/x509/root_cgo_darwin.go	2019-03-15 11:34:53.323180897 -0700
@@ -270,11 +270,20 @@
 import "C"
 import (
	"errors"
+	"io/ioutil"
+	"os"
	"unsafe"
 )

 func loadSystemRoots() (*CertPool, error) {
	roots := NewCertPool()
+	if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
+		data, err := ioutil.ReadFile(file)
+		if err == nil {
+			roots.AppendCertsFromPEM(data)
+			return roots, nil
+		}
+	}

	var data C.CFDataRef = 0
	var untrustedData C.CFDataRef = 0
diff -Naur a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go
--- a/src/crypto/x509/root_darwin.go	2019-03-15 11:33:55.920232337 -0700
+++ b/src/crypto/x509/root_darwin.go	2019-03-15 11:36:21.205123541 -0700
@@ -92,6 +92,14 @@
		verifyCh    = make(chan rootCandidate)
	)

+	if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
+		data, err := ioutil.ReadFile(file)
+		if err == nil {
+			roots.AppendCertsFromPEM(data)
+			return roots, nil
+		}
+	}
+
	// Using 4 goroutines to pipe into verify-cert seems to be
	// about the best we can do. The verify-cert binary seems to
	// just RPC to another server with coarse locking anyway, so
diff -Naur a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go
--- a/src/crypto/x509/root_unix.go	2019-03-15 11:33:55.920232337 -0700
+++ b/src/crypto/x509/root_unix.go	2019-03-15 11:37:15.737326340 -0700
@@ -38,6 +38,13 @@

 func loadSystemRoots() (*CertPool, error) {
	roots := NewCertPool()
+	if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
+		data, err := ioutil.ReadFile(file)
+		if err == nil {
+			roots.AppendCertsFromPEM(data)
+			return roots, nil
+		}
+	}

	files := certFiles
	if f := os.Getenv(certFileEnv); f != "" {