afssl

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: Apache-2.0 Imports: 11 Imported by: 4

README

AFSSL

SSL Generator.

Install

go get github.com/aacfactory/afssl

Usage

config := afssl.CertificateConfig{
    Country:            "CN",
    Province:           "Shanghai",
    City:               "Shanghai",
    Organization:       "AACFACTORY",
    OrganizationalUnit: "TECH",
    CommonName:         "AFSSL",
    IPs:                nil,
    Emails:             nil,
    DNSNames:           nil,
}
// ca
caPEM, caKeyPEM, caErr := afssl.GenerateCertificate(config, afssl.CA())
if caErr != nil {
    t.Error("ca", caErr)
    return
}
fmt.Println(string(caPEM))
fmt.Println(string(caKeyPEM))
// server
serverPEM, serverKeyPEM, serverErr := afssl.GenerateCertificate(config, afssl.WithParent(caPEM, caKeyPEM))
if serverErr != nil {
    t.Error("server", serverErr)
    return
}
fmt.Println(string(serverPEM))
fmt.Println(string(serverKeyPEM))
// client
clientPEM, clientKeyPEM, clientErr := afssl.GenerateCertificate(config, afssl.WithParent(caPEM, caKeyPEM))
if clientErr != nil {
    t.Error("client", clientErr)
    return
}
fmt.Println(string(clientPEM))
fmt.Println(string(clientKeyPEM))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCertificate added in v1.1.0

func GenerateCertificate(config CertificateConfig, opts ...GenerateCertificateOption) (certPEM []byte, keyPEM []byte, err error)

Types

type CertificateConfig added in v1.1.0

type CertificateConfig struct {
	Country            string
	Province           string
	City               string
	Organization       string
	OrganizationalUnit string
	CommonName         string
	IPs                []string
	Emails             []string
	DNSNames           []string
}

type GenerateCertificateOption added in v1.1.0

type GenerateCertificateOption func(*GenerateCertificateOptions) error

func CA added in v1.1.0

func WithExpirationDays added in v1.1.0

func WithExpirationDays(days int) GenerateCertificateOption

func WithParent added in v1.1.0

func WithParent(certPEM []byte, keyPEM []byte) GenerateCertificateOption

func WithSerialNumber added in v1.1.0

func WithSerialNumber(sn uint64) GenerateCertificateOption

type GenerateCertificateOptions added in v1.1.0

type GenerateCertificateOptions struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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