Skip to content

Commit 2c8b70e

Browse files
committed
crypto/x509: revert SystemCertPool implementation for Windows
Updates #18609 Change-Id: I8306135660f52cf625bed4c7f53f632e527617de Reviewed-on: https://go-review.googlesource.com/35265 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Russ Cox <[email protected]> Reviewed-by: Quentin Smith <[email protected]>
1 parent fcfd918 commit 2c8b70e

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

doc/go1.8.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,6 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
809809

810810
<dl id="crypto_x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
811811
<dd>
812-
<p> <!-- CL 30578 -->
813-
<a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a>
814-
is now implemented on Windows.
815-
</p>
816-
817812
<p> <!-- CL 24743 -->
818813
PSS signatures are now supported.
819814
</p>

src/crypto/x509/cert_pool.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
package x509
66

7-
import "encoding/pem"
7+
import (
8+
"encoding/pem"
9+
"errors"
10+
"runtime"
11+
)
812

913
// CertPool is a set of certificates.
1014
type CertPool struct {
@@ -26,6 +30,11 @@ func NewCertPool() *CertPool {
2630
// Any mutations to the returned pool are not written to disk and do
2731
// not affect any other pool.
2832
func SystemCertPool() (*CertPool, error) {
33+
if runtime.GOOS == "windows" {
34+
// Issue 16736, 18609:
35+
return nil, errors.New("crypto/x509: system root pool is not available on Windows")
36+
}
37+
2938
return loadSystemRoots()
3039
}
3140

src/crypto/x509/root_windows.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ func (c *Certificate) systemVerify(opts *VerifyOptions) (chains [][]*Certificate
226226
}
227227

228228
func loadSystemRoots() (*CertPool, error) {
229+
// TODO: restore this functionality on Windows. We tried to do
230+
// it in Go 1.8 but had to revert it. See Issue 18609.
231+
// Returning (nil, nil) was the old behavior, prior to CL 30578.
232+
return nil, nil
233+
229234
const CRYPT_E_NOT_FOUND = 0x80092004
230235

231236
store, err := syscall.CertOpenSystemStore(0, syscall.StringToUTF16Ptr("ROOT"))

src/crypto/x509/x509_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net"
2525
"os/exec"
2626
"reflect"
27+
"runtime"
2728
"strings"
2829
"testing"
2930
"time"
@@ -1477,6 +1478,9 @@ func TestMultipleRDN(t *testing.T) {
14771478
}
14781479

14791480
func TestSystemCertPool(t *testing.T) {
1481+
if runtime.GOOS == "windows" {
1482+
t.Skip("not implemented on Windows; Issue 16736, 18609")
1483+
}
14801484
_, err := SystemCertPool()
14811485
if err != nil {
14821486
t.Fatal(err)

0 commit comments

Comments
 (0)