x509util

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package x509util provides utility functions for parsing and handling X.509 certificates and keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCAELSICertificateDER

func NewCAELSICertificateDER(subAttrs ELSIName, keyparams KeyParams) (subPrivKey any, DERCert []byte, err error)

func NewCAELSICertificateRaw

func NewCAELSICertificateRaw(subAttrs ELSIName, keyparams KeyParams) (subPrivKey any, subCert *x509.Certificate, err error)

func ParseCertificateFromPEM

func ParseCertificateFromPEM(pemData []byte) (cert *x509.Certificate, issuer *ELSIName, subject *ELSIName, b64der string, err error)

ParseCertificate extracts the first certificate from the given PEM string

func ParseEIDASCertB64Der

func ParseEIDASCertB64Der(certDer string) (cert *x509.Certificate, issuer *ELSIName, subject *ELSIName, err error)

func ParseEIDASCertDer

func ParseEIDASCertDer(rawCert []byte) (cert *x509.Certificate, issuer *ELSIName, subject *ELSIName, err error)

Types

type ELSIName

type ELSIName struct {
	Country                string `json:"country,omitempty"`
	Organization           string `json:"organization,omitempty"`
	OrganizationalUnit     string `json:"organizational_unit,omitempty"`
	Locality               string `json:"locality,omitempty"`
	Province               string `json:"province,omitempty"`
	StreetAddress          string `json:"street_address,omitempty"`
	PostalCode             string `json:"postal_code,omitempty"`
	SerialNumber           string `json:"serial_number,omitempty"`
	CommonName             string `json:"common_name,omitempty"`
	GivenName              string `json:"given_name,omitempty"`
	Surname                string `json:"surname,omitempty"`
	OrganizationIdentifier string `json:"organization_identifier,omitempty"`
	EmailAddress           string `json:"email_address,omitempty"`
}

ELSIName represents an X.509 distinguished name. This only includes the common elements of a DN. Note that ELSIName is only an approximation of the X.509 structure. If an accurate representation is needed, asn1.Unmarshal the raw subject or issuer as an [RDNSequence].

func ParseEIDASNameFromATVSequence

func ParseEIDASNameFromATVSequence(rdn []pkix.AttributeTypeAndValue) *ELSIName

func (ELSIName) String

func (e ELSIName) String() string

func (ELSIName) ToATVSequence

func (n ELSIName) ToATVSequence() (ret []pkix.AttributeTypeAndValue)

type KeyParams

type KeyParams struct {
	Ed25519Key bool
	EcdsaCurve string
	RsaBits    int
	ValidFrom  string
	ValidFor   time.Duration
}

type PEMCert

type PEMCert []byte

func NewCAELSICertificatePEM

func NewCAELSICertificatePEM(subAttrs ELSIName, keyparams KeyParams) (subPrivKey jwk.Key, subCert PEMCert, err error)

func NewCertificate

func NewCertificate(issCert PEMCert, issPrivKey jwk.Key, subAttrs ELSIName, keyparams KeyParams) (subPrivKey jwk.Key, subCert PEMCert, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL