Documentation
¶
Overview ¶
Package code contains the go-openssl certificate generation logic used by the CLI and by other Go code that needs to create plain or encrypted PEM assets programmatically.
Index ¶
- func DecryptPEM(content []byte, secret string) ([]byte, error)
- func ReadCertificateFile(path string, secret string) (*x509.Certificate, error)
- func ReadPEMFile(path string, secret string) ([]byte, error)
- func ReadPrivateKeyFile(path string, secret string) (any, error)
- func ReadPublicKeyFile(path string, secret string) (any, error)
- type App
- type Command
- type Generator
- type IOStreams
- type Options
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptPEM ¶ added in v0.0.6
DecryptPEM returns plain PEM content. Unencrypted PEM content is returned as-is.
func ReadCertificateFile ¶ added in v0.0.6
func ReadCertificateFile(path string, secret string) (*x509.Certificate, error)
ReadCertificateFile reads a plain or encrypted certificate PEM file.
func ReadPEMFile ¶ added in v0.0.6
ReadPEMFile reads a PEM file and decrypts it when it contains a QuicksGo encrypted PEM envelope.
func ReadPrivateKeyFile ¶ added in v0.0.6
ReadPrivateKeyFile reads a plain or encrypted private key PEM file.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App wires the go-openssl CLI, its command tree, and the certificate generator.
type Command ¶
Command defines an executable CLI command that can be converted into a Cobra command.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator coordinates filesystem writes and cryptographic generation helpers.
func NewGenerator ¶
func NewGenerator() *Generator
NewGenerator creates the default certificate generator.
type Options ¶
type Options struct {
// Algorithm selects the key algorithm used to generate the certificate.
Algorithm string
// OutputDir is the directory where the PEM files are written.
OutputDir string
// CommonName is the subject common name included in the certificate.
CommonName string
// DNSNames lists the DNS subject alternative names included in the certificate.
DNSNames []string
// IPAddresses lists the IP subject alternative names included in the certificate.
IPAddresses []string
// Organization is the subject organization included in the certificate.
Organization string
// ValidForDays controls the certificate validity period in days.
ValidForDays int
// RSAKeySize is the RSA key size in bits when Algorithm is rsa.
RSAKeySize int
// ECCCurve selects the elliptic curve when Algorithm is ecc.
ECCCurve string
// Salt mixes additional data into the random source used for generation.
Salt string
// CertFileName is the certificate PEM file name written inside OutputDir.
CertFileName string
// KeyFileName is the private key PEM file name written inside OutputDir.
KeyFileName string
// PublicKeyFileName is the public key PEM file name written inside OutputDir.
PublicKeyFileName string
// SignedBy is the CA certificate PEM path used to sign the generated certificate.
SignedBy string
// CAKeyFile is the CA private key PEM path used to sign the generated certificate.
CAKeyFile string
// IsCA marks the generated certificate as a certificate authority.
IsCA bool
// EncryptSecret encrypts generated PEM files when set. It must be at least 32 bytes.
EncryptSecret string
// SignedBySecret decrypts an encrypted SignedBy certificate when set.
SignedBySecret string
// CAKeySecret decrypts an encrypted CAKeyFile private key when set.
CAKeySecret string
}
Options configures the generated certificate, keys, output paths, and algorithm-specific settings.
type Result ¶
type Result struct {
// Algorithm is the normalized algorithm used for generation.
Algorithm string
// OutputDir is the normalized output directory used for the generated files.
OutputDir string
// CertificatePath is the path to the generated certificate PEM file.
CertificatePath string
// PrivateKeyPath is the path to the generated private key PEM file.
PrivateKeyPath string
// PublicKeyPath is the path to the generated public key PEM file.
PublicKeyPath string
// Encrypted reports whether the generated PEM files were encrypted.
Encrypted bool
}
Result describes the generated PEM artifacts and the effective generation parameters.
func GenerateCertificates ¶
GenerateCertificates generates PEM certificate assets using the default generator.