Skip to content

Commit ad641e5

Browse files
committed
cmd/docker-trust: use stdlib's x509.SystemCertPool on Windows
The `tlsconfig.SystemCertPool` utility in go-connections was added in [docker/go-connections@55aadc3], at which time Go stdlib didn't support system-pools ([x509.SystemCertPool]) on Windows, so an empty pool was constructed. Support for system pools on Windows originally added in Go 1.8 (through [golang/go@05471e9]), but reverted, and re-implemented in Go 1.18 (through [golang/go@3544082]). Go 1.18 and up now implement this, but, unlike Linux, which uses a pure-Go implementation, certificate validation is handled by the system: > On macOS and Windows, certificate verification is handled by system APIs, > but the package aims to apply consistent validation rules across operating > systems. On macOS and Windows, x509.SystemCertPool returns an empty Pool, with the `systemPool` set to `true` (see [loadSystemRoots]). This must be considered an implementation detail; custom CAs can be appended to this pool, and handled as usual. This patch removes the special handling on Windows, removing the dependency on go-connections for this part. [docker/go-connections@55aadc3]: docker/go-connections@55aadc3 [golang/go@05471e9]: golang/go@05471e9 [golang/go@3544082]: golang/go@3544082 [x509.SystemCertPool]: https://pkg.go.dev/crypto/x509#SystemCertPool [loadSystemRoots]: https://cs.opensource.google/go/go/+/refs/tags/go1.26.1:src/crypto/x509/root_windows.go;l=15-17 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 950401c commit ad641e5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cmd/docker-trust/internal/registry/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ package registry
44
import (
55
"context"
66
"crypto/tls"
7+
"crypto/x509"
78
"fmt"
89
"net/http"
910
"os"
1011
"path/filepath"
1112

1213
"github.com/docker/distribution/registry/client/transport"
13-
"github.com/docker/go-connections/tlsconfig"
1414
"github.com/sirupsen/logrus"
1515
)
1616

@@ -48,7 +48,7 @@ func loadTLSConfig(ctx context.Context, directory string, tlsConfig *tls.Config)
4848
switch filepath.Ext(f.Name()) {
4949
case ".crt":
5050
if tlsConfig.RootCAs == nil {
51-
systemPool, err := tlsconfig.SystemCertPool()
51+
systemPool, err := x509.SystemCertPool()
5252
if err != nil {
5353
return invalidParam(fmt.Errorf("unable to get system cert pool: %w", err))
5454
}

0 commit comments

Comments
 (0)