gcert

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 14 Imported by: 1

README

gcert

Golang module to generate a self-signed X.509 certificate

Modified version of:
https://go.dev/src/crypto/tls/generate_cert.go

Docs

Documentation

Usage

import `github.com/mbrostami/gcert`

Then call Generate function:

err := gcert.Generate("abc.com", "./", opts...)
Options
  • gcert.WithStartDate
  • gcert.WithDuration
  • gcert.WithCA
  • gcert.WithRSABits
  • gcert.WithP224
  • gcert.WithP256
  • gcert.WithP384
  • gcert.WithP521
  • gcert.WithED25519

Documentation

Index

Constants

View Source
const (
	CurveP224 = "P224"
	CurveP256 = "P256"
	CurveP384 = "P384"
	CurveP521 = "P521"
)

Variables

This section is empty.

Functions

func Generate

func Generate(host, dest string, opts ...Option) error

Generate a self-signed X.509 certificate for a TLS server. Outputs 'cert.pem' and 'key.pem' into dest directory and will overwrite existing files. host is a comma-separated hostnames and IPs to generate a certificate for

func ParsePemCertFile added in v1.0.2

func ParsePemCertFile(path string) (*x509.Certificate, error)

ParsePemCertFile parses the given pem certificate file

func ParsePemKeyFile added in v1.0.2

func ParsePemKeyFile(path string) (any, error)

ParsePemKeyFile parses the given pem key file

func Verify added in v1.0.2

func Verify(rootCertPath, certPath, dnsName string) error

Verify the certificate's signature

Types

type Option

type Option func(*options)

func WithCA

func WithCA() Option

WithCA cert should be its own Certificate Authority

func WithCertFileName added in v1.0.2

func WithCertFileName(certFileName string) Option

WithCertFileName the generated cert file name (default cert.pem)

func WithDuration

func WithDuration(duration time.Duration) Option

WithDuration duration that certificate is valid for

func WithED25519

func WithED25519() Option

WithED25519 generate an Ed25519 key

func WithKeyFileName added in v1.0.2

func WithKeyFileName(keyFileName string) Option

WithKeyFileName the generated key file name (default key.pem)

func WithP224

func WithP224() Option

WithP224 ECDSA P224 curve to use to generate a key

func WithP256

func WithP256() Option

WithP256 ECDSA P256 (recommended) curve to use to generate a key

func WithP384

func WithP384() Option

WithP384 ECDSA P384 curve to use to generate a key

func WithP521

func WithP521() Option

WithP521 ECDSA P521 curve to use to generate a key

func WithRSABits

func WithRSABits(bits int) Option

WithRSABits size of RSA key to generate. Ignored if --ecdsa-curve is set

func WithSignByParent added in v1.0.2

func WithSignByParent(parentCertPath, parentKeyPath string) Option

WithSignByParent signs the generated certificate as parent (path of cert and key file of the signer)

func WithStartDate

func WithStartDate(startDate string) Option

WithStartDate creation date formatted as Jan 1 15:04:05 2011

Jump to

Keyboard shortcuts

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