Beispiel #1
0
func GetServer(ipaddr string, port int, uname string, upass []byte) (svr http.Server, err error) {
	ca_f, ee_f, key_f, err := transport.LoadCertsKeys(uname, upass)
	if err != nil {
		return svr, err
	}
	config, err := transport.GetConfig(ca_f, ee_f, key_f)

	if err != nil {
		return svr, err
	}
	//config.ServerName = "agent-1.hj.com"
	svr.Addr = ipaddr + ":" + strconv.Itoa(port)
	svr.TLSConfig = config

	return
}
Beispiel #2
0
func GetClient() (client *http.Client, err error) {
	ca_f, ee_f, key_f, err := transport.L2()
	if err != nil {
		return nil, err
	}
	config, err := transport.GetConfig(ca_f, ee_f, key_f)
	if err != nil {
		return nil, err
	}
	config.InsecureSkipVerify = false
	config.SkipVerifyHostname = true
	trans := http.Transport{
		TLSClientConfig: config,
	}
	client = new(http.Client)
	client.Transport = &trans
	return client, nil

}