Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

certificate issue on windows 11 #136

Open
malinka-2233 opened this issue Jul 17, 2023 · 2 comments
Open

certificate issue on windows 11 #136

malinka-2233 opened this issue Jul 17, 2023 · 2 comments

Comments

@malinka-2233
Copy link

Hey! There seems to be a problem with windows 11 and certificate auth. I use this to connect:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/masterzen/winrm"
)

func main() {
	key, err := os.ReadFile("key2.pem")
	if err != nil {
		panic(err)
	}
	cert, err := os.ReadFile("client2.pem")
	if err != nil {
		panic(err)
	}
	end := winrm.NewEndpoint("192.168.0.101", 5986, true, true, nil, cert, key, 0)

	params := winrm.NewParameters("PT60S", "en-US", 153600)
	params.TransportDecorator = func() winrm.Transporter {
		return &winrm.ClientAuthRequest{}
	}
	client, err := winrm.NewClientWithParameters(end, "win", "pass", params)
	if err != nil {
		panic(err)
	}
	out, errout, _, err := client.RunWithContextWithString(context.TODO(), "ipconfig", "")

	if err != nil {
		panic(err)
	}
	fmt.Println(out)
	fmt.Println(errout)
}

client2.pem was imported on the system and a certmapping was created using the same method as i used for windows 10.
But it does not connect and throws an error like this:
panic: unknown error Post "https://clientip:5986/wsman": read tcp myip:54434->clientip:5986: read: connection reset by peer

pywinrm connects using the same certs without issues. go auth on basic https works fine too.

@malinka-2233
Copy link
Author

Can be fixed by using decade-old forks of http and tls from https://launchpad.net/~gwacl-hackers/gwacl/trunk :(

@malinka-2233
Copy link
Author

it can also be avoided by limiting the tls version to 1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant