Ejemplo n.º 1
0
func setupNewHTTPSServer(maxConns uint64, idleTimeout time.Duration) (*server.Server, error) {
	s := basicServer(maxConns, idleTimeout)
	var err error
	ready := make(chan string)
	wait := func(addr string) {
		ready <- addr
	}
	go func(err *error) {
		if *err = s.ServeHTTPS("localhost:0", "key.pem", "cert.pem", wait); err != nil {
			log.Errorf("Unable to serve: %s", err)
		}
	}(&err)
	<-ready
	if err != nil {
		return nil, err
	}
	serverCertificate, err = keyman.LoadCertificateFromFile("cert.pem")
	return s, err
}
Ejemplo n.º 2
0
func setupNewHTTPSServer(maxConns uint64, idleTimeout time.Duration) (string, error) {
	s := basicServer(maxConns, idleTimeout)
	var err error
	ready := make(chan string)
	wait := func(addr string) {
		log.Debugf("Started HTTPS proxy server at %s", addr)

		ready <- addr
	}
	go func(err *error) {
		if *err = s.ListenAndServeHTTPS("localhost:0", "key.pem", "cert.pem", wait); err != nil {
			log.Errorf("Unable to serve: %v", err)
		}
	}(&err)
	addr := <-ready
	if err != nil {
		return "", err
	}
	serverCertificate, err = keyman.LoadCertificateFromFile("cert.pem")
	return addr, err
}