Ejemplo n.º 1
0
func (o *OpenSSLRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
	if r.URL.Scheme == "http" {
		return http.DefaultTransport.RoundTrip(r)
	}

	conn, err := net.Dial("tcp", r.URL.Host)
	if err != nil {
		return nil, err
	}

	sslConn, err := gossl.NewConn(o.ctx, conn)
	if err != nil {
		return nil, err
	}

	if err := sslConn.Handshake(); err != nil {
		return nil, err
	}

	return response, nil
}
Ejemplo n.º 2
0
func OpenSSLDial(network, address string) (net.Conn, error) {
	logger.Printf("initializing connection to network=%q address=%q", network, address)
	internalConn, err := net.Dial(network, address)
	if err != nil {
		return nil, err
	}

	logger.Printf("creating ssl connection")
	conn, err := gossl.NewConn(context, internalConn)
	if err != nil {
		return nil, err
	}

	logger.Printf("performing handshake localaddr=%q remoteaddr=%q", conn.LocalAddr(), conn.RemoteAddr())
	if err := conn.Handshake(); err != nil {
		return nil, err
	}

	logger.Printf("successful ssl connection")
	return conn, nil
}