func LogSTHInfoFromCert(cert *x509.Certificate) (*LogSTHInfo, error) {
	for _, ext := range cert.Extensions {
		if ext.Id.Equal(OIDExtensionCTSTH) {
			var sthInfo LogSTHInfo
			rest, err := tls.Unmarshal(ext.Value, &sthInfo)
			if err != nil {
				return nil, fmt.Errorf("failed to unmarshal STH: %v", err)
			} else if len(rest) > 0 {
				return nil, fmt.Errorf("trailing data (%d bytes) after STH", len(rest))
			}
			return &sthInfo, nil
		}
	}
	return nil, errors.New("no STH extension found")
}
LogSTHInfoFromCert retrieves the STH information embedded in a certificate.
package x509ext
import (
	"errors"
	"fmt"
	"github.com/google/certificate-transparency-go/asn1"
	"github.com/google/certificate-transparency-go/tls"
	"github.com/google/certificate-transparency-go/x509"
	ct "github.com/google/certificate-transparency-go"
)
var OIDExtensionCTSTH = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 5}
var OIDExtKeyUsageCTMinimalGossip = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 6}
type LogSTHInfo struct {
	LogURL            []byte   `tls:"maxlen:255"`
	Version           tls.Enum `tls:"maxval:255"`
	TreeSize          uint64
	Timestamp         uint64
	SHA256RootHash    ct.SHA256Hash
	TreeHeadSignature ct.DigitallySigned
}