Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewKeyPair ¶
func NewKeyPair() (crypto.PublicKey, crypto.PrivateKey, error)
Types ¶
type CA ¶
type CA struct { Dir string SerialFile string Serial int64 Config *TLSCertificateConfig }
func InitCA ¶
InitCA ensures a certificate authority structure exists in the given directory, creating it if necessary:
<dir>/ ca/ root.crt - Root certificate bundle. cert.crt - Signing certificate key.key - Private key serial.txt - Stores the highest serial number generated by this CA
func (*CA) MakeClientConfig ¶
MakeClientConfig creates a folder containing certificates for the given client:
<CA.dir>/ <username>/ root.crt - Root certificate bundle. cert.crt - Client certificate key.key - Private key
The generated certificate has the following attributes:
CommonName: username ExtKeyUsage: ExtKeyUsageClientAuth
func (*CA) MakeServerCert ¶
func (ca *CA) MakeServerCert(name string, hostnames []string) (*TLSCertificateConfig, error)
MakeServerCert creates a folder containing certificates for the given server:
<CA.dir>/ <name>/ root.crt - Root certificate bundle. cert.crt - Server certificate key.key - Private key
The generated certificate has the following attributes:
CommonName: hostnames[0] DNSNames subjectAltNames containing all specified hostnames IPAddresses subjectAltNames containing all specified hostnames which are IP addresses ExtKeyUsage: ExtKeyUsageServerAuth
type TLSCertificateConfig ¶
type TLSCertificateConfig struct { CAFile string CertFile string KeyFile string Roots []*x509.Certificate Certs []*x509.Certificate Key crypto.PrivateKey }
Click to show internal directories.
Click to hide internal directories.