Documentation ¶
Index ¶
- Constants
- func CertificateBytesToPem(derBytes []byte) []byte
- func CertificateChainToPem(certs []*x509.Certificate) []byte
- func CertificateToPem(c *x509.Certificate) []byte
- func CommonName(n string) *pkix.Name
- func CreateCertificate(spec *Specification) (*x509.Certificate, []byte, error)
- func DNAsString(dn pkix.Name) string
- func ExtKeyUsages(usages []x509.ExtKeyUsage) []string
- func GetCertPool(in GenericCertificatePool, filter bool) (*x509.CertPool, error)
- func GetCertificate(in GenericCertificate, filter bool) (*x509.Certificate, *x509.CertPool, error)
- func GetCertificateChain(in GenericCertificateChain, filter bool) ([]*x509.Certificate, error)
- func GetPrivateKey(key GenericPrivateKey) (interface{}, error)
- func GetPublicKey(key GenericPublicKey) (interface{}, error)
- func GetSignatureFromPem(pemData []byte) ([]byte, string, []*x509.Certificate, error)
- func GetTime(in interface{}) (time.Time, error)
- func IsSelfSigned(cert *x509.Certificate) bool
- func KeyUsages(usages x509.KeyUsage) []string
- func MatchDN(n pkix.Name, p pkix.Name) error
- func NormalizeDN(dn pkix.Name) string
- func ParseCertificate(data []byte) (*x509.Certificate, error)
- func ParseCertificateChain(data []byte, filter bool) ([]*x509.Certificate, error)
- func ParseDN(dn string) (*pkix.Name, error)
- func ParsePrivateKey(data []byte) (interface{}, error)
- func ParsePublicKey(data []byte) (interface{}, error)
- func PemBlockForCertificate(cert interface{}) *pem.Block
- func PemBlockForPrivateKey(priv interface{}) *pem.Block
- func PemBlockForPublicKey(priv interface{}, gen ...bool) *pem.Block
- func RootPoolFromFile(pemfile string, useOS bool, fss ...vfs.FileSystem) (*x509.CertPool, error)
- func SignatureBytesToPem(algo string, data []byte, certs ...*x509.Certificate) []byte
- func SystemCertPool() (*x509.CertPool, error)
- func VerifyCertificate(cert *x509.Certificate, intermediates GenericCertificateChain, ...) error
- type GenericCertificate
- type GenericCertificateChain
- type GenericCertificatePool
- type GenericPrivateKey
- type GenericPublicKey
- type KeyUsage
- type PublicKeySource
- type Specification
- type Usages
Constants ¶
const ( KIND_HASH_ALGORITHM = "hash algorithm" KIND_SIGN_ALGORITHM = "signing algorithm" KIND_NORM_ALGORITHM = "normalization algorithm" KIND_VERIFY_ALGORITHM = "signature verification algorithm" KIND_PUBLIC_KEY = "public key" KIND_PRIVATE_KEY = "private key" KIND_CERTIFICATE = "certificate" KIND_CERTPOOL = "certificate pool" KIND_SIGNATURE = "signature" KIND_DIGEST = "digest" )
const CertificatePEMBlockType = "CERTIFICATE"
CertificatePEMBlockType defines the type of a certificate pem block.
const MediaTypePEM = "application/x-pem-file"
MediaTypePEM defines the media type for PEM formatted signature data.
const SignaturePEMBlockAlgorithmHeader = "Signature Algorithm"
SignaturePEMBlockAlgorithmHeader defines the header in a signature pem block where the signature algorithm is defined.
const SignaturePEMBlockType = "SIGNATURE"
SignaturePEMBlockType defines the type of a signature pem block.
Variables ¶
This section is empty.
Functions ¶
func CertificateBytesToPem ¶
func CertificateChainToPem ¶
func CertificateChainToPem(certs []*x509.Certificate) []byte
func CertificateToPem ¶
func CertificateToPem(c *x509.Certificate) []byte
func CommonName ¶
func CreateCertificate ¶
func CreateCertificate(spec *Specification) (*x509.Certificate, []byte, error)
CreateCertificate creates a certificate and additionally returns a PEM encoded representation.
func DNAsString ¶
func ExtKeyUsages ¶
func ExtKeyUsages(usages []x509.ExtKeyUsage) []string
func GetCertPool ¶
func GetCertPool(in GenericCertificatePool, filter bool) (*x509.CertPool, error)
func GetCertificate ¶
func GetCertificate(in GenericCertificate, filter bool) (*x509.Certificate, *x509.CertPool, error)
func GetCertificateChain ¶
func GetCertificateChain(in GenericCertificateChain, filter bool) ([]*x509.Certificate, error)
func GetPrivateKey ¶
func GetPrivateKey(key GenericPrivateKey) (interface{}, error)
func GetPublicKey ¶
func GetPublicKey(key GenericPublicKey) (interface{}, error)
func GetSignatureFromPem ¶
GetSignatureFromPem returns a signature and certificated contained in a PEM block list.
func IsSelfSigned ¶
func IsSelfSigned(cert *x509.Certificate) bool
func NormalizeDN ¶
func ParseCertificate ¶
func ParseCertificate(data []byte) (*x509.Certificate, error)
func ParseCertificateChain ¶
func ParseCertificateChain(data []byte, filter bool) ([]*x509.Certificate, error)
func ParsePrivateKey ¶
func ParsePublicKey ¶
func PemBlockForCertificate ¶
func PemBlockForPrivateKey ¶
func PemBlockForPublicKey ¶
func RootPoolFromFile ¶
func SignatureBytesToPem ¶
func SignatureBytesToPem(algo string, data []byte, certs ...*x509.Certificate) []byte
func SystemCertPool ¶
func VerifyCertificate ¶
func VerifyCertificate(cert *x509.Certificate, intermediates GenericCertificateChain, rootCerts GenericCertificatePool, name *pkix.Name, ts ...*time.Time) error
Types ¶
type GenericCertificate ¶
type GenericCertificate interface{}
GenericCertificate can be everything mappable by GetCertificate to an appropriate x509.Certificate.
type GenericCertificateChain ¶
type GenericCertificateChain interface{}
GenericCertificateChain can be everything mappable by GetCertificateChain to an appropriate list of x509.Certificates. GenericCertificateChain is always a GenericCertificatePool.
type GenericCertificatePool ¶
type GenericCertificatePool interface{}
GenericCertificatePool can be everything mappable by GetCertPool to an appropriate x509.CertPool.
func AddCertificateToPool ¶
func AddCertificateToPool(in GenericCertificatePool, chain ...GenericCertificateChain) (GenericCertificatePool, error)
type GenericPrivateKey ¶
type GenericPrivateKey interface{}
GenericPrivateKey can be everything somebody can map to an appropriate PrivateKey.
type GenericPublicKey ¶
type GenericPublicKey interface{}
GenericPublicKey can be everything somebody can map to an appropriate PublicKey.
type KeyUsage ¶
type KeyUsage interface { String() string AddTo(*x509.Certificate) }
func GetKeyUsage ¶
func GetKeyUsage(opt interface{}) KeyUsage
func ParseKeyUsage ¶
type PublicKeySource ¶
type Specification ¶
type Specification struct { // RootCAs is used to verify a certificate chain. // Self-signed CAs must be added here to be accepted as part // of a chain. RootCAs GenericCertificatePool // IsCA requests a certificate for a CA. IsCA bool PublicKey GenericPublicKey // CAPrivateKey is the private key used for signing. // It must be the key for the first certificate in the chain // (if given). CAPrivateKey GenericPrivateKey CAChain GenericCertificateChain // SkipVerify can be set to true to skip the verification // of the given certificate chain. SkipVerify bool Subject pkix.Name Usages Usages Validity time.Duration NotBefore *time.Time Hosts []string }
Specification specified the context for the certificate creation.