Documentation
¶
Overview ¶
Package converter detects certificate/key container formats, decodes them into a common Bundle of objects, and encodes bundles into target formats. When a target cannot represent the bundle, encoding fails with an explanation instead of dropping data.
Index ¶
Constants ¶
const MinJKSPassword = 6
MinJKSPassword is Java's minimum keystore password length.
Variables ¶
var ErrImpossible = errors.New("conversion not possible")
ErrImpossible marks conversions the target format cannot represent.
var ErrUnsupported = errors.New("unsupported format")
ErrUnsupported marks formats that are recognised but cannot be read.
var Targets = []struct { Name, Description string }{ {"pem", "PEM text: certificates, keys (PKCS#8), CSRs, public keys"}, {"der", "binary DER of exactly one object"}, {"pkcs7", "PKCS#7 / .p7b certificate bundle (certificates only)"}, {"pkcs8", "PKCS#8 private key (encrypted with --out-password)"}, {"pkcs1", "PKCS#1 RSA private or public key"}, {"sec1", "SEC1 EC private key"}, {"spki", "PKIX SubjectPublicKeyInfo public key"}, {"pkcs12", "PKCS#12 / PFX keystore or truststore"}, {"jks", "Java KeyStore"}, {"openssh", "OpenSSH private key"}, {"ssh", "OpenSSH authorized_keys public key line(s)"}, {"rfc4716", "RFC 4716 SSH2 public key"}, }
Targets lists output formats with a short description.
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle struct {
Format Format
Encrypted bool // container or key was password protected
Objects []Object
Notes []string
}
Bundle is the decoded content of one or more inputs.
func Decode ¶
func Decode(data []byte, o DecodeOptions) (*Bundle, error)
Decode detects the format of data and decodes its objects.
func (*Bundle) Certificates ¶
func (b *Bundle) Certificates() []*x509.Certificate
Certificates returns all certificates.
type Contents ¶
type Contents struct {
PrivateKeys int `json:"private_keys"`
PublicKeys int `json:"public_keys"`
CSRs int `json:"certificate_requests"`
Leaf int `json:"leaf_certificates"`
Intermediates int `json:"intermediate_certificates"`
Roots int `json:"root_certificates"`
}
Contents counts what a bundle holds, classifying certificates by role.
type DecodeOptions ¶
type DecodeOptions struct {
Password keys.PasswordFunc // store / file password
// KeyPassword is used for JKS private key entries whose password differs
// from the store password; nil reuses the store password.
KeyPassword keys.PasswordFunc
}
DecodeOptions supply passwords on demand.
type EncodeOptions ¶
type EncodeOptions struct {
Password []byte // encrypts keys / keystores; required for pkcs12 and jks
DER bool // binary output where both encodings exist (pkcs1/pkcs8/sec1/spki/pkcs7/csr)
Alias string // alias for the key entry in pkcs12/jks
}
EncodeOptions control output encoding.
type Format ¶
type Format string
Format identifies a container format.
const ( FormatPEM Format = "pem" FormatDER Format = "der" FormatPKCS7 Format = "pkcs7" FormatPKCS8 Format = "pkcs8" FormatPKCS1 Format = "pkcs1" FormatSEC1 Format = "sec1" FormatSPKI Format = "spki" FormatCSR Format = "csr" FormatPKCS12 Format = "pkcs12" FormatJKS Format = "jks" FormatJCEKS Format = "jceks" FormatOpenSSH Format = "openssh" FormatSSHPublic Format = "ssh" FormatRFC4716 Format = "rfc4716" FormatUnknown Format = "unknown" )
func (Format) Description ¶
Description is a human-readable name for a detected format.
type Object ¶
type Object struct {
Kind Kind
Alias string
Cert *x509.Certificate
Key crypto.PrivateKey
Public crypto.PublicKey
CSR *x509.CertificateRequest
Comment string
// Trusted marks JKS/PKCS#12 trusted-certificate entries.
Trusted bool
Created time.Time
}
Object is one item decoded from a container.