func Fingerprint(cert *x509.Certificate) string {
	return fmt.Sprintf("%x", sha256.Sum256(cert.Raw))
}
Fingerprint returns the fingerprint of the certificate
package cert
import (
	"crypto/rsa"
	"crypto/sha256"
	"crypto/tls"
	"crypto/x509"
	"encoding/pem"
	"fmt"
	"github.com/pkg/errors"
)
type Info struct {
	keypair tls.Certificate
	ca      *x509.Certificate
}
func NewInfo(keypair tls.Certificate, ca *x509.Certificate) *Info {
	return &Info{
		keypair: keypair,
		ca:      ca,
	}
}
func (c *Info) KeyPair() tls.Certificate {
	return c.keypair
}
func (c *Info) CA() *x509.Certificate {
	return c.ca
}
func (c *Info) PublicKey() []byte {
	data := c.KeyPair().Certificate[0]
	return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: data})
}
func (c *Info) PrivateKey() []byte {
	key, ok := c.KeyPair().PrivateKey.(*rsa.PrivateKey)
	if !ok {
		return nil
	}
	data := x509.MarshalPKCS1PrivateKey(key)
	return pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: data})
}
func (c *Info) Fingerprint() string {
	fingerprint, err := FingerprintStr(string(c.PublicKey()))
	if err != nil {
		panic("invalid public key material")
	}
	return fingerprint
}