tls

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertMatchesPrivateKey

func CertMatchesPrivateKey(cert *x509.Certificate, privateKey *rsa.PrivateKey) bool

CertMatchesPrivateKey tests to make the sure cert and private key match

func EncodeCertAndKeyToPEM

func EncodeCertAndKeyToPEM(certDER []byte, certKey *rsa.PrivateKey) ([]byte, []byte, error)

EncodeCertAndKeyToPEM encodes the cert and key to PEM

func GenerateAndWriteAllCerts added in v0.21.0

func GenerateAndWriteAllCerts(outDir string, privateCACert *x509.Certificate, privateCAKey *rsa.PrivateKey) error

GenerateAndWriteAllCerts generates the full set of required certs for chik blockchain and writes them to a given directory If privateCACert and privateCAKey are both nil, a new private CA will be generated

func GenerateCASignedCert

func GenerateCASignedCert(caCert *x509.Certificate, caKey *rsa.PrivateKey) ([]byte, *rsa.PrivateKey, error)

GenerateCASignedCert generates a new key/cert signed by the given CA

func GenerateNewCA

func GenerateNewCA() ([]byte, *rsa.PrivateKey, error)

GenerateNewCA generates a new CA

func GetChikCACertAndKey

func GetChikCACertAndKey() ([]byte, []byte)

GetChikCACertAndKey returns the cert and key bytes for chik_ca.crt and chik_ca.key

func ParsePemCertificate

func ParsePemCertificate(certPem []byte) (*x509.Certificate, error)

ParsePemCertificate parses a certificate

func ParsePemKey

func ParsePemKey(keyPem []byte) (*rsa.PrivateKey, error)

ParsePemKey parses a key

func WriteCertAndKey

func WriteCertAndKey(certDER []byte, certKey *rsa.PrivateKey, certKeyBase string) ([]byte, []byte, error)

WriteCertAndKey Returns the written cert bytes, key bytes, and error

Types

type CertificateKeyPair added in v0.21.0

type CertificateKeyPair struct {
	// CertificateDER contains the X.509 certificate in ASN.1 DER binary format.
	// This is the raw binary representation of the certificate, not PEM encoded.
	CertificateDER []byte

	// PrivateKey contains the RSA private key corresponding to the public key
	// embedded in the certificate.
	PrivateKey *rsa.PrivateKey
}

CertificateKeyPair represents a TLS certificate and its corresponding private key used for secure communications. This pair can be encoded to PEM with the EncodeCertAndKeyToPEM function.

type ChikCertificates added in v0.21.0

type ChikCertificates struct {
	PrivateCA        *CertificateKeyPair
	PrivateCrawler   *CertificateKeyPair
	PrivateDaemon    *CertificateKeyPair
	PrivateDatalayer *CertificateKeyPair
	PublicDatalayer  *CertificateKeyPair
	PrivateFarmer    *CertificateKeyPair
	PublicFarmer     *CertificateKeyPair
	PrivateFullNode  *CertificateKeyPair
	PublicFullNode   *CertificateKeyPair
	PrivateHarvester *CertificateKeyPair
	PublicIntroducer *CertificateKeyPair
	PrivateTimelord  *CertificateKeyPair
	PublicTimelord   *CertificateKeyPair
	PrivateWallet    *CertificateKeyPair
	PublicWallet     *CertificateKeyPair
}

ChikCertificates contains the data for all Chik TLS certificate-key pairs

func GenerateAllCerts

func GenerateAllCerts(privateCACert *x509.Certificate, privateCAKey *rsa.PrivateKey) (*ChikCertificates, error)

GenerateAllCerts generates the full set of required certs for chik blockchain If privateCACert and privateCAKey are both nil, a new private CA will be generated

Jump to

Keyboard shortcuts

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