func newWinRMClient(config *Config, auth authMethod) (*winrm.Client, error) {
	clientCert, clientKey := auth.getClientCert()
	username, password := auth.getBasic()
	endpoint := winrm.NewEndpoint(config.Host, config.Port, config.HTTPS, config.SkipVerifyCert, config.CaCert, clientKey, clientCert, 0)
	client, err := winrm.NewClient(endpoint, username, password)
	return client, err
}
newWinRMClient creates a WinRM client based upon the config and the authMethod.
package winrm
import (
	"bytes"
	"crypto/sha1"
	"crypto/tls"
	"crypto/x509"
	"encoding/hex"
	"encoding/pem"
	"fmt"
	"io"
	"net/http"
	"github.com/secrethub/secrethub-cli/internals/cli/ui"
	"github.com/secrethub/secrethub-go/internals/errio"
	"github.com/masterzen/winrm"
)
var (
	errWinRM = errio.Namespace("winrm")
	ErrCannotReachHost   = errWinRM.Code("cannot_reach_host").ErrorPref("Cannot reach the Client host: %s")
	ErrNoPeerCertificate = errWinRM.Code("no_peer_cert").Error("Could not get the peer certificate")
	ErrCertNotTrusted    = errWinRM.Code("peer_not_trusted").Error("Peer certificate is not trusted")
	ErrExecutingCommand  = errWinRM.Code("executing_command").ErrorPref("An error occurred while executing the command : %s")
	ErrCertAuthNoClientKey  = errWinRM.Code("no_client_key_certificate_authentication").Error("No client key was supplied to use for certificate authentication")
	ErrCertAuthNoClientCert = errWinRM.Code("no_client_certificate_certificate_authentication").Error("No client certificate was supplied to use for certificate authentication")
	ErrBasicAuthNoUsername = errWinRM.Code("no_username_basic_authentication").Error("No username was supplied to use for basic authentication")
	ErrBasicAuthNoPassword = errWinRM.Code("no_password_basic_authentication").Error("No password was supplied to use for basic authentication")
)
type Config struct {
	Host string
	Port int
	HTTPS bool
	SkipVerifyCert bool
	CaCert         []byte
}
type authMethod interface {
	getClientCert() ([]byte, []byte)
	getBasic() (string, string)
}
type authBasic struct {
	username string
	password string
}
func (ab *authBasic) getClientCert() ([]byte, []byte) {
	return []byte{}, []byte{}
}
func (ab *authBasic) getBasic() (string, string) {
	return ab.username, ab.password
}
func NewBasicClient(config *Config, username, password string) (*Client, error) {
	if username == "" {
		return nil, ErrBasicAuthNoUsername
	}
	if password == "" {
		return nil, ErrBasicAuthNoPassword
	}
	authMethod := &authBasic{
		username: username,
		password: password,
	}
	client, err := newWinRMClient(config, authMethod)
	return &Client{
		Client: client,
		auth:   authMethod,
		config: config,
	}, err
}
type authCert struct {
	clientCert []byte
	clientKey  []byte
}
func (ac *authCert) getClientCert() ([]byte, []byte) {
	return ac.clientCert, ac.clientKey
}
func (ac *authCert) getBasic() (string, string) {
	return "", ""
}
func NewCertClient(config *Config, clientCert, clientKey []byte) (*Client, error) {
	if clientKey == nil {
		return nil, ErrCertAuthNoClientKey
	}
	if clientCert == nil {
		return nil, ErrCertAuthNoClientCert
	}
	authMethode := &authCert{
		clientCert: clientCert,
		clientKey:  clientKey,
	}
	client, err := newWinRMClient(config, authMethode)
	return &Client{
		Client: client,
		auth:   authMethode,
		config: config,
	}, err
}