func retrieveCACert(ctx context.Context, addr string) (*x509.Certificate, error) {
	netConn, err := new(net.Dialer).DialContext(ctx, "tcp", addr)
	if err != nil {
		return nil, err
	}

	conn := tls.Client(netConn, &tls.Config{InsecureSkipVerify: true})
	if err = conn.Handshake(); err != nil {
		_ = netConn.Close()
		return nil, err
	}
	defer func() {
		_ = conn.Close()
		_ = netConn.Close()
	}()

	for _, cert := range conn.ConnectionState().PeerCertificates {
		if cert.IsCA {
			return cert, nil
		}
	}

	return nil, errors.New("no CA certificate presented by remote server")
}
// retrieveCACert establishes an insecure TLS connection to addr and attempts
// to retrieve the CA cert presented by the server. If no CA cert is presented,
// retrieveCACert will returns nil, nil.
retrieveCACert establishes an insecure TLS connection to addr and attempts
to retrieve the CA cert presented by the server. If no CA cert is presented,
retrieveCACert will returns nil, nil.
// retrieveCACert establishes an insecure TLS connection to addr and attempts // to retrieve the CA cert presented by the server . If no CA cert is presented // retrieveCACert will returns nil nil .
func retrieveCACert(ctx context.Context, addr string) (*x509.Certificate, error) {
	netConn, err := new(net.Dialer).DialContext(ctx, "tcp", addr)
	if err != nil {
		return nil, err
	}
	conn := tls.Client(netConn, &tls.Config{InsecureSkipVerify: true})
	if err = conn.Handshake(); err != nil {
		_ = netConn.Close()
		return nil, err
	}
	defer func() {
		_ = conn.Close()
		_ = netConn.Close()
	}()
	for _, cert := range conn.ConnectionState().PeerCertificates {
		if cert.IsCA {
			return cert, nil
		}
	}
	return nil, errors.New("no CA certificate presented by remote server")
}
func retrieveCACert ( ctx context . Context , addr string ) ( * x509 . Certificate , error ) { netConn , err := new ( net . Dialer ) . DialContext ( ctx , " " , addr ) if err != nil { return nil , err } conn := tls . Client ( netConn , & tls . Config { InsecureSkipVerify : true } ) if err = conn . Handshake ( ) ; err != nil { _ = netConn . Close ( ) return nil , err } defer func ( ) { _ = conn . Close ( ) _ = netConn . Close ( ) } ( ) for _ , cert := range conn . ConnectionState ( ) . PeerCertificates { if cert . IsCA { return cert , nil } } return nil , errors . New ( " " ) }
retrieveCACert establishes an insecure TLS connection to addr and attempts
to retrieve the CA cert presented by the server.
retrieveCACert establishes an insecure TLS connection to addr and attempts to retrieve the CA cert presented by the server .