nixpkgs/pkgs/development/compilers/go/ssl-cert-file-1.15.patch

77 lines
2.2 KiB
Diff
Raw Normal View History

2020-06-28 02:50:42 +02:00
diff --git a/src/crypto/x509/root_darwin_amd64.go b/src/crypto/x509/root_darwin_amd64.go
2020-08-12 05:10:25 +02:00
index ce88de025e..258ecc45d1 100644
2020-06-28 02:50:42 +02:00
--- a/src/crypto/x509/root_darwin_amd64.go
+++ b/src/crypto/x509/root_darwin_amd64.go
2020-08-12 05:10:25 +02:00
@@ -10,6 +10,7 @@ import (
2020-06-28 02:50:42 +02:00
"bytes"
2020-08-12 05:10:25 +02:00
macOS "crypto/x509/internal/macos"
2020-06-28 02:50:42 +02:00
"fmt"
+ "io/ioutil"
"os"
"strings"
)
2020-08-12 05:10:25 +02:00
@@ -25,6 +26,14 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
2020-06-28 02:50:42 +02:00
var loadSystemRootsWithCgo func() (*CertPool, error)
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)
2020-08-12 05:10:25 +02:00
diff --git a/src/crypto/x509/root_darwin_ios.go b/src/crypto/x509/root_darwin_ios.go
index 5ecc4911b3..14b4205c00 100644
--- a/src/crypto/x509/root_darwin_ios.go
+++ b/src/crypto/x509/root_darwin_ios.go
2020-06-28 02:50:42 +02:00
@@ -6,6 +6,11 @@
package x509
+import (
+ "io/ioutil"
+ "os"
+)
+
func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate, err error) {
return nil, nil
}
@@ -14,6 +19,14 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
var loadSystemRootsWithCgo func() (*CertPool, error)
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
+ }
+ }
p := NewCertPool()
p.AppendCertsFromPEM([]byte(systemRootsPEM))
return p, nil
diff --git a/src/crypto/x509/root_unix.go b/src/crypto/x509/root_unix.go
index b48e618a65..195c1ff25a 100644
--- a/src/crypto/x509/root_unix.go
+++ b/src/crypto/x509/root_unix.go
@@ -42,6 +42,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 != "" {