File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,8 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...CLIOption)
281281 }
282282 filterResourceAttributesEnvvar ()
283283
284+ cli .setAllowNegativex509 ()
285+
284286 return nil
285287}
286288
@@ -474,6 +476,43 @@ func (cli *DockerCli) getDockerEndPoint() (ep docker.Endpoint, err error) {
474476 return resolveDockerEndpoint (cli .contextStore , cn )
475477}
476478
479+ // setAllowNegativex509 is an escape hatch that sets the GODEBUG=x509negativeserial
480+ // environment variable for this process and sub-processes (such as CLI plugins)
481+ func (cli * DockerCli ) setAllowNegativex509 () {
482+ cn := cli .CurrentContext ()
483+ meta , err := cli .ContextStore ().GetMetadata (cn )
484+ if err != nil {
485+ return
486+ }
487+
488+ fieldName := "allowx509negativeserialdonotuse"
489+
490+ var config any
491+ var ok bool
492+ switch m := meta .Metadata .(type ) {
493+ case DockerContext :
494+ config , ok = m .AdditionalFields [fieldName ]
495+ if ! ok {
496+ return
497+ }
498+ case map [string ]any :
499+ config , ok = m [fieldName ]
500+ if ! ok {
501+ return
502+ }
503+ default :
504+ return
505+ }
506+
507+ v , ok := config .(string )
508+ if ! ok {
509+ return
510+ }
511+ if v == "1" {
512+ _ = os .Setenv ("GODEBUG" , "x509negativeserial=1" )
513+ }
514+ }
515+
477516func (cli * DockerCli ) initialize () error {
478517 cli .init .Do (func () {
479518 cli .dockerEndpoint , cli .initErr = cli .getDockerEndPoint ()
You can’t perform that action at this time.
0 commit comments