cert

package
v0.0.0-...-e70b4cf Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var P11Context *pkcs11Context

Functions

func ComputeSKI

func ComputeSKI(hashType crypto.HashType, pub interface{}) ([]byte, error)

func CreateCACertificate

func CreateCACertificate(cfg *CACertificateConfig) error

CreateCACertificate - create ca cert file

func CreateCSR

func CreateCSR(cfg *CSRConfig) error

func CreateP11Key

func CreateP11Key(handle *pkcs11.P11Handle, keyType crypto.KeyType, keyId string) ([]byte, crypto.PrivateKey, error)

CreatePrivKey - create pkcs11 private key

func CreatePrivKey

func CreatePrivKey(keyType crypto.KeyType, keyPath, keyFile string, isTLS bool) (key crypto.PrivateKey, err error)

CreatePrivKey - create private key file

func GenerateCSRTemplate

func GenerateCSRTemplate(privKey crypto.PrivateKey,
	country, locality, province, organizationalUnit, organization, commonName string) (*x509.CertificateRequest, error)

func GenerateCertTemplate

func GenerateCertTemplate(cfg *GenerateCertTemplateConfig) (*x509.Certificate, error)

func InitP11Handle

func InitP11Handle(handle *pkcs11.P11Handle)

func IssueCertificate

func IssueCertificate(cfg *IssueCertificateConfig) error

IssueCertificate - issue certification

func ParseCertificate

func ParseCertificate(certFilePath string) (*x509.Certificate, error)

ParseCertificate - parse certification

func ParseCertificateRequest

func ParseCertificateRequest(csrFilePath string) (*x509.CertificateRequest, error)

ParseCertificateRequest - parse certification request

func ParseCertificateToJson

func ParseCertificateToJson(certFilePath string) (string, error)

func ParseP11PrivKey

func ParseP11PrivKey(handle *pkcs11.P11Handle, keySpecJson []byte) (crypto.PrivateKey, error)

Types

type CACertificateConfig

type CACertificateConfig struct {
	PrivKey            crypto.PrivateKey
	HashType           crypto.HashType
	CertPath           string
	CertFileName       string
	Country            string
	Locality           string
	Province           string
	OrganizationalUnit string
	Organization       string
	CommonName         string
	ExpireYear         int32
	Sans               []string
}

CACertificateConfig contains necessary parameters for creating private key.

type CSRConfig

type CSRConfig struct {
	PrivKey            crypto.PrivateKey
	CsrPath            string
	CsrFileName        string
	Country            string
	Locality           string
	Province           string
	OrganizationalUnit string
	Organization       string
	CommonName         string
}

CSRConfig contains necessary parameters for creating csr.

type GenerateCertTemplateConfig

type GenerateCertTemplateConfig struct {
	PrivKey            crypto.PrivateKey
	IsCA               bool
	Country            string
	Locality           string
	Province           string
	OrganizationalUnit string
	Organization       string
	CommonName         string
	ExpireYear         int32
	Sans               []string
	KeyUsages          []x509.KeyUsage
	ExtKeyUsages       []x509.ExtKeyUsage
}

GenerateCertTemplateConfig contains necessary parameters for creating private key.

type IssueCertificateConfig

type IssueCertificateConfig struct {
	HashType              crypto.HashType
	IsCA                  bool
	IssuerPrivKeyFilePath string
	IssuerCertFilePath    string
	IssuerPrivKeyPwd      []byte
	CsrFilePath           string
	CertPath              string
	CertFileName          string
	ExpireYear            int32
	Sans                  []string
	//Uuid                  string
	KeyUsages    []x509.KeyUsage
	ExtKeyUsages []x509.ExtKeyUsage
}

IssueCertificateConfig contains necessary parameters for issuing cert.

Jump to

Keyboard shortcuts

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