File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -474,6 +474,43 @@ func (cli *DockerCli) getDockerEndPoint() (ep docker.Endpoint, err error) {
474474 return resolveDockerEndpoint (cli .contextStore , cn )
475475}
476476
477+ // setAllowNegativex509 is an escape hatch that sets the GODEBUG=x509negativeserial
478+ // environment variable for this process and sub-processes (such as CLI plugins)
479+ func (cli * DockerCli ) setAllowNegativex509 () {
480+ cn := cli .CurrentContext ()
481+ meta , err := cli .ContextStore ().GetMetadata (cn )
482+ if err != nil {
483+ return
484+ }
485+
486+ fieldName := "allowx509negativeserialdonotuse"
487+
488+ var config any
489+ var ok bool
490+ switch m := meta .Metadata .(type ) {
491+ case DockerContext :
492+ config , ok = m .AdditionalFields [fieldName ]
493+ if ! ok {
494+ return
495+ }
496+ case map [string ]any :
497+ config , ok = m [fieldName ]
498+ if ! ok {
499+ return
500+ }
501+ default :
502+ return
503+ }
504+
505+ v , ok := config .(string )
506+ if ! ok {
507+ return
508+ }
509+ if v == "1" {
510+ _ = os .Setenv ("GODEBUG=x509negativeserial" , "1" )
511+ }
512+ }
513+
477514func (cli * DockerCli ) initialize () error {
478515 cli .init .Do (func () {
479516 cli .dockerEndpoint , cli .initErr = cli .getDockerEndPoint ()
@@ -490,6 +527,7 @@ func (cli *DockerCli) initialize() error {
490527 cli .baseCtx = context .Background ()
491528 }
492529 cli .initializeFromClient ()
530+ cli .setAllowNegativex509 ()
493531 })
494532 return cli .initErr
495533}
You can’t perform that action at this time.
0 commit comments