about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/go/ssl-cert-file-2-dev.patch
blob: a5be2685998e608b39558447fc1d90796bbfd5e8 (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
diff --git a/src/crypto/x509/root_darwin.go b/src/crypto/x509/root_darwin.go
index 05593bb105..a6a11eeec1 100644
--- a/src/crypto/x509/root_darwin.go
+++ b/src/crypto/x509/root_darwin.go
@@ -11,6 +11,7 @@ import (
 	"bytes"
 	macOS "crypto/x509/internal/macos"
 	"fmt"
+	"io/ioutil"
 	"os"
 	"strings"
 )
@@ -22,6 +23,14 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
 }
 
 func loadSystemRoots() (*CertPool, error) {
+	if file := os.Getenv("NIX_SSL_CERT_FILE"); file != "" {
+		data, err := ioutil.ReadFile(file)
+		if err == nil {
+			roots := NewCertPool()
+			roots.AppendCertsFromPEM(data)
+			return roots, nil
+		}
+	}
 	var trustedRoots []*Certificate
 	untrustedRoots := make(map[string]bool)
 
diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go
index dede825edd..ffb3caf4a4 100644
--- a/src/crypto/x509/root_unix.go
+++ b/src/crypto/x509/root_unix.go
@@ -9,6 +9,7 @@ package x509
 
 import (
 	"io/fs"
+	"io/ioutil"
 	"os"
 	"path/filepath"
 	"strings"
@@ -32,6 +33,13 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
 
 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 != "" {