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 @@ -282,6 +282,8 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...CLIOption)
282282 }
283283 filterResourceAttributesEnvvar ()
284284
285+ cli .setAllowNegativex509 ()
286+
285287 return nil
286288}
287289
@@ -475,6 +477,43 @@ func (cli *DockerCli) getDockerEndPoint() (ep docker.Endpoint, err error) {
475477 return resolveDockerEndpoint (cli .contextStore , cn )
476478}
477479
480+ // setAllowNegativex509 is an escape hatch that sets the GODEBUG=x509negativeserial
481+ // environment variable for this process and sub-processes (such as CLI plugins)
482+ func (cli * DockerCli ) setAllowNegativex509 () {
483+ cn := cli .CurrentContext ()
484+ meta , err := cli .ContextStore ().GetMetadata (cn )
485+ if err != nil {
486+ return
487+ }
488+
489+ fieldName := "allowx509negativeserialdonotuse"
490+
491+ var config any
492+ var ok bool
493+ switch m := meta .Metadata .(type ) {
494+ case DockerContext :
495+ config , ok = m .AdditionalFields [fieldName ]
496+ if ! ok {
497+ return
498+ }
499+ case map [string ]any :
500+ config , ok = m [fieldName ]
501+ if ! ok {
502+ return
503+ }
504+ default :
505+ return
506+ }
507+
508+ v , ok := config .(string )
509+ if ! ok {
510+ return
511+ }
512+ if v == "1" {
513+ _ = os .Setenv ("GODEBUG" , "x509negativeserial=1" )
514+ }
515+ }
516+
478517func (cli * DockerCli ) initialize () error {
479518 cli .init .Do (func () {
480519 cli .dockerEndpoint , cli .initErr = cli .getDockerEndPoint ()
You can’t perform that action at this time.
0 commit comments