x509x

package module
v0.0.0-...-71e49fc Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CertificatePEMBlockType              = "CERTIFICATE"
	CrlPEMBlockType                      = "X509 CRL"
	CsrPEMBlockType                      = "CERTIFICATE REQUEST"
	OldCsrPEMBlockType                   = "NEW CERTIFICATE REQUEST"
	RsaPrivateKeyPEMBlockType            = "RSA PRIVATE KEY"
	EcdsaPrivateKeyPEMBlockType          = "EC PRIVATE KEY"
	Pkcs8PrivateKeyPEMBlockType          = "PRIVATE KEY"
	EncryptedPKCS8PrivateKeyPEMBLockType = "ENCRYPTED PRIVATE KEY"
)

Variables

This section is empty.

Functions

func CreateCertificateRequest

func CreateCertificateRequest(template *x509.CertificateRequest) (csr []byte, pemBytes []byte, err error)

CreateCertificateRequest create CSR and return PEM privateKey: signer private key

func EncodeCertificateToPEM

func EncodeCertificateToPEM(derBytes []byte) []byte

func EncodePrivateKeyToPEM

func EncodePrivateKeyToPEM(privateKey PrivateKey) ([]byte, error)

func ExtKeyUsageToStr

func ExtKeyUsageToStr(keyUsage x509.ExtKeyUsage) string

func KeyUsageToStr

func KeyUsageToStr(keyUsage x509.KeyUsage) string

func ParseCSR

func ParseCSR(csrBytes []byte) (*x509.CertificateRequest, error)

ParseCSR parse x509 CSR PEM block

func ParseCertificate

func ParseCertificate(certBytes []byte) (*x509.Certificate, error)

ParseCertificate parse x509 certificate PEM block or DER bytes

func ParseCertificateChain

func ParseCertificateChain(pemBytes []byte) ([]*x509.Certificate, error)

func PrivateKeyAlgorithm

func PrivateKeyAlgorithm(priv PrivateKey) x509.SignatureAlgorithm

PrivateKeyAlgorithm return private key algorithm

func RandomSerial

func RandomSerial() *big.Int

func StrToExtKeyUsage

func StrToExtKeyUsage(s string) x509.ExtKeyUsage

func StrToKeyUsage

func StrToKeyUsage(s string) x509.KeyUsage

func ValidCertificateAlgorithm

func ValidCertificateAlgorithm(isCA bool, keyAlgorithm x509.SignatureAlgorithm, signatureAlgorithm x509.SignatureAlgorithm) error

ValidCertificateAlgorithm check

func VerifySignature

func VerifySignature(pub PublicKey, hash []byte, signature []byte) bool

Types

type PrivateKey

type PrivateKey interface {
	crypto.PrivateKey
	crypto.Signer
}

PublicKey PrivateKey and Signer interfaces crypto.PrivateKey의 설명을 보면 함수가 다 있다고 함.

func GenerateKey

func GenerateKey(algorithm x509.SignatureAlgorithm) (privateKey PrivateKey, err error)

GenerateKey generate private and public key pair

func ParsePrivateKey

func ParsePrivateKey(keyPemBytes []byte) (PrivateKey, error)

ParsePrivateKey parse pem formatted priate key

type PublicKey

type PublicKey interface {
	Equal(x crypto.PublicKey) bool
}

Jump to

Keyboard shortcuts

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