Documentation
¶
Index ¶
- Constants
- Variables
- func Encode(b CertBundle) ([]byte, error)
- func EncodePKCS12(b CertBundle, password string) ([]byte, error)
- func GetExtensionValue(cert *x509.Certificate, oid string) (string, error)
- func LoadCert(CaPath, CertPath, KeyPath string) (*tls.Config, error)
- func NewCSR(key crypto.Signer, cn string, dnsNames []string, ips []net.IP) ([]byte, error)
- func NewCertPool(certs ...*x509.Certificate) *x509.CertPool
- func ParseCSR(b []byte) (*x509.CertificateRequest, error)
- func ParseDERCert(b []byte) (*x509.Certificate, error)
- func ParseDERKey(der []byte, password string) (crypto.PrivateKey, error)
- func ParsePEM(certBytes, caBytes, keyBytes []byte, password string) (*x509.Certificate, []*x509.Certificate, crypto.PrivateKey, error)
- func ParsePEMCert(b []byte) (*x509.Certificate, []*x509.Certificate, error)
- func ParsePEMKey(b []byte, password string) (crypto.PrivateKey, error)
- func ParsePKCS12(pfxBytes []byte, password string) (*x509.Certificate, []*x509.Certificate, crypto.PrivateKey, error)
- type CABundle
- type CARequest
- type CSRRequest
- type CertBundle
- func Decode(bundleData []byte) (CertBundle, error)
- func MustCertFromFile(certFile, caFile, keyFile string) CertBundle
- func NewCABundleWithoutKey(caBytes []byte) (CertBundle, error)
- func NewCert(cert *x509.Certificate, pool []*x509.Certificate, key crypto.PrivateKey) (CertBundle, error)
- func NewCertBundle(certBytes, keyBytes []byte) (CertBundle, error)
- func NewCertBundleWithoutKey(certBytes []byte) (CertBundle, error)
- type ClientRequest
- type Manager
- type Option
- type ServerRequest
Constants ¶
const (
Bits2048 = 2048
)
Variables ¶
var (
DefaultCommonName = "default"
)
var OIDStringToNameMap = map[string]string{
"2.5.29.14": "Subject Key Identifier",
"2.5.29.15": "Key Usage",
"2.5.29.37": "Extended Key Usage",
"2.5.29.35": "Authority Key Identifier",
"2.5.29.19": "Basic Constraints",
"2.5.29.17": "Subject Alt Name",
"2.5.29.32": "Certificate Policies",
"2.5.29.30": "Name Constraints",
"2.5.29.31": "CRL Distribution Points",
"1.3.6.1.5.5.7.1.1": "Authority Info Access",
"2.5.29.20": "CRL Number",
}
Functions ¶
func Encode ¶
func Encode(b CertBundle) ([]byte, error)
func EncodePKCS12 ¶ added in v0.9.0
func EncodePKCS12(b CertBundle, password string) ([]byte, error)
EncodePKCS12 is b's certificate, key and chain as a PKCS#12 file encrypted with password - by modern algorithms, AES-256 and PBKDF2-SHA256, which OpenSSL 3 reads without -legacy.
func GetExtensionValue ¶
func GetExtensionValue(cert *x509.Certificate, oid string) (string, error)
func NewCSR ¶ added in v0.9.0
NewCSR is a PEM certificate request for key's public key - what a requester sends to have it signed while keeping key to itself.
func NewCertPool ¶
func NewCertPool(certs ...*x509.Certificate) *x509.CertPool
func ParseCSR ¶ added in v0.9.0
func ParseCSR(b []byte) (*x509.CertificateRequest, error)
ParseCSR reads a PEM or DER certificate request and checks its signature, which proves the requester holds the private key of the public key it sends.
func ParseDERCert ¶
func ParseDERCert(b []byte) (*x509.Certificate, error)
func ParseDERKey ¶
func ParseDERKey(der []byte, password string) (crypto.PrivateKey, error)
func ParsePEM ¶
func ParsePEM(certBytes, caBytes, keyBytes []byte, password string) (*x509.Certificate, []*x509.Certificate, crypto.PrivateKey, error)
func ParsePEMCert ¶
func ParsePEMCert(b []byte) (*x509.Certificate, []*x509.Certificate, error)
func ParsePEMKey ¶
func ParsePEMKey(b []byte, password string) (crypto.PrivateKey, error)
func ParsePKCS12 ¶
func ParsePKCS12(pfxBytes []byte, password string) (*x509.Certificate, []*x509.Certificate, crypto.PrivateKey, error)
Types ¶
type CABundle ¶
type CABundle interface {
CertBundle
SignClient(req *ClientRequest) (CertBundle, error)
SignServer(req *ServerRequest) (CertBundle, error)
// SignCSR returns the certificate without a key: the key stays with the requester.
SignCSR(csr *x509.CertificateRequest, req *CSRRequest) (CertBundle, error)
SignCA(req *CARequest) (CABundle, error)
}
func MustCAFromFile ¶
func NewCA ¶
func NewCA(cert *x509.Certificate, pool []*x509.Certificate, key crypto.PrivateKey) (CABundle, error)
type CSRRequest ¶ added in v0.9.0
type CSRRequest struct {
ExtKeyUsage []x509.ExtKeyUsage // at least one
CommonName string
DNSNames []string
IPs []net.IP
ValidPeriod time.Duration // 0: until the CA expires
KeepChain bool
}
CSRRequest is what a CSR is signed into. The CA decides the identity: the CSR contributes its public key, and any name it asks for must be one of these.
type CertBundle ¶
type CertBundle interface {
CAs() []*x509.Certificate
IsCA() bool
Cert() *x509.Certificate
CertDER() []byte
CertPEM() []byte
CertTLS() tls.Certificate
Key() crypto.PrivateKey
KeyDER() []byte
KeyPEM() []byte
Dump(certFile, keyFile string) error
common.Debuggable
}
func Decode ¶
func Decode(bundleData []byte) (CertBundle, error)
func MustCertFromFile ¶
func MustCertFromFile(certFile, caFile, keyFile string) CertBundle
func NewCABundleWithoutKey ¶
func NewCABundleWithoutKey(caBytes []byte) (CertBundle, error)
func NewCert ¶
func NewCert(cert *x509.Certificate, pool []*x509.Certificate, key crypto.PrivateKey) (CertBundle, error)
func NewCertBundle ¶
func NewCertBundle(certBytes, keyBytes []byte) (CertBundle, error)
func NewCertBundleWithoutKey ¶
func NewCertBundleWithoutKey(certBytes []byte) (CertBundle, error)
type ClientRequest ¶
type Manager ¶
type Manager interface {
CABundle
ClientFiles(req *ClientRequest, certFile, keyFile string) error
ServerFiles(req *ServerRequest, certFile, keyFile string) error
}
type Option ¶
type Option func(m *manager)