cert

package
v0.0.0-...-48ef5be Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 21 Imported by: 0

README

  1. 使用Go语言生成自签CA证书,这篇文章讲的挺好的: https://foreverzmyer.hashnode.dev/go-cert

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEcdsaKey

func GenerateEcdsaKey()

func MainInner

func MainInner(dir, parent, name string)

创建证书颁发机构证书(根证书签名)

func MainLeaf

func MainLeaf(dir, parent, name string, ips, hosts []string)

创建TLS使用的证书(证书颁发机构证书签名)

func MakeRoot

func MakeRoot(dir, name string)

创建根证书(自签名)

func SignECDSA

func SignECDSA(plainText []byte, priFileName string) (rText, sText []byte)

签名

func VerifyECDSA

func VerifyECDSA(plainText, rText, sText []byte, pubFileName string) bool

验签

func WriteFile

func WriteFile(dir, key, cert string, keyPEMBlock, certPEMBlock []byte) (err error)

func X509SignECDSA

func X509SignECDSA(plainText []byte, keyPem []byte) (signature string)

签名

func X509VerifyECDSA

func X509VerifyECDSA(plainText []byte, signature string, certPem []byte) (ok bool, err error)

验签

Types

type Cert

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

func New

func New(keyPem, certPem []byte) (cert *Cert, err error)

func NewSelfSigned

func NewSelfSigned() (cert *Cert, err error)

func (*Cert) MakeEcdsa

func (c *Cert) MakeEcdsa(certMode CertMode, ips, hosts []string) (privPEM, certPEM []byte, err error)

MakeEcdsa certMode: root, inner, leaf

type CertMode

type CertMode uint8
const (
	CertModeRoot  CertMode = 1
	CertModeInner CertMode = 2
	CertModeLeaf  CertMode = 3
)

type Spki

type Spki struct {
	Algorithm        pkix.AlgorithmIdentifier
	SubjectPublicKey asn1.BitString
}

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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