func (idp *IdentityProvider) Cert() (*pem.Block, error) {
	if v := idp.pemCert.Load(); v != nil {
		return v.(*pem.Block), nil
	}
	certFile, err := idp.PubkeyFile()
	if err != nil {
		return nil, err
	}
	fp, err := os.Open(certFile)
	if err != nil {
		return nil, err
	}
	defer fp.Close()
	buf, err := ioutil.ReadAll(fp)
	if err != nil {
		return nil, err
	}
	cert, _ := pem.Decode(buf)
	if cert == nil {
		return nil, errors.New("failed to decode idp cert")
	}
	idp.pemCert.Store(cert)
	return cert, nil
}
Cert returns a *pem.Block value that corresponds to the IdP's certificate.
package saml
import (
	"bytes"
	"encoding/base64"
	"encoding/pem"
	"encoding/xml"
	"io/ioutil"
	"net/http"
	"os"
	"sync/atomic"
	"time"
	"github.com/pressly/saml/xmlsec"
	"github.com/pkg/errors"
)
type Session struct {
	ID         string
	CreateTime time.Time
	ExpireTime time.Time
	Index      string
	NameID         string
	Groups         []string
	UserID         string
	UserFullname   string
	UserName       string
	UserEmail      string
	UserCommonName string
	UserSurname    string
	UserGivenName  string
}
type IdpAuthnRequest struct {
	IDP *IdentityProvider
	Address string
	RelayState              string
	RequestBuffer           []byte
	Request                 AuthnRequest
	ServiceProviderMetadata *Metadata
	ACSEndpoint             *IndexedEndpoint
	Assertion               *Assertion
	AssertionBuffer         []byte
	Response                *Response
}
type IdentityProvider struct {
	EntityID string
	MetadataURL string
	SSOURL string
	SecurityOpts
	KeyFile string
	CertFile string
	PrivkeyPEM string
	PubkeyPEM string
	pemCert atomic.Value
	SPMetadataURL string
	SPMetadata    *Metadata
	SPAcsURL string
}
func (idp *IdentityProvider) PrivkeyFile() (string, error) {
	if idp.KeyFile != "" {
		return idp.KeyFile, nil
	}
	if idp.PrivkeyPEM != "" {
		return writeFile([]byte(idp.PrivkeyPEM))
	}
	return "", errors.New("missing idp private key")
}
func (idp *IdentityProvider) PubkeyFile() (string, error) {
	if idp.CertFile != "" {
		return validateKeyFile(idp.CertFile, nil)
	}
	if idp.PubkeyPEM != "" {
		return validateKeyFile(writeFile([]byte(idp.PubkeyPEM)))
	}
	return "", errors.New("missing idp public key")
}