tls

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 23 Imported by: 8 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxCertificateLen = 2 * constants.KiB
)

Variables

View Source
var (
	ErrCertificateTooLarge                   = fmt.Errorf("tls: certificate length is greater than %d", MaxCertificateLen)
	ErrMalformedCertificate                  = errors.New("tls: malformed certificate")
	ErrMalformedTBSCertificate               = errors.New("tls: malformed tbs certificate")
	ErrMalformedVersion                      = errors.New("tls: malformed version")
	ErrMalformedSerialNumber                 = errors.New("tls: malformed serial number")
	ErrMalformedSignatureAlgorithmIdentifier = errors.New("tls: malformed signature algorithm identifier")
	ErrMalformedIssuer                       = errors.New("tls: malformed issuer")
	ErrMalformedValidity                     = errors.New("tls: malformed validity")
	ErrMalformedSPKI                         = errors.New("tls: malformed spki")
	ErrMalformedPublicKeyAlgorithmIdentifier = errors.New("tls: malformed public key algorithm identifier")
	ErrMalformedSubjectPublicKey             = errors.New("tls: malformed subject public key")
	ErrMalformedOID                          = errors.New("tls: malformed oid")
	ErrInvalidRSAPublicKey                   = errors.New("tls: invalid RSA public key")
	ErrInvalidRSAModulus                     = errors.New("tls: invalid RSA modulus")
	ErrInvalidRSAPublicExponent              = errors.New("tls: invalid RSA public exponent")
	ErrRSAModulusNotPositive                 = errors.New("tls: RSA modulus is not a positive number")
	ErrUnsupportedRSAModulusBitLen           = errors.New("tls: unsupported RSA modulus bitlen")
	ErrRSAModulusIsEven                      = errors.New("tls: RSA modulus is an even number")
	ErrUnsupportedRSAPublicExponent          = errors.New("tls: unsupported RSA public exponent")
	ErrFailedUnmarshallingEllipticCurvePoint = errors.New("tls: failed to unmarshal elliptic curve point")
	ErrUnknownPublicKeyAlgorithm             = errors.New("tls: unknown public key algorithm")
)
View Source
var (
	ErrUnsupportedAlgorithm     = errors.New("tls: cannot verify signature: unsupported algorithm")
	ErrECDSAVerificationFailure = errors.New("tls: ECDSA verification failure")
)

Functions

func CheckSignature

func CheckSignature(cert *Certificate, msg []byte, signature []byte) error

CheckSignature verifies that the signature is a valid signature over signed from the certificate.

Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L793-L797 Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/x509.go#L816-L879

func InitNodeStakingKeyPair

func InitNodeStakingKeyPair(keyPath, certPath string) error

InitNodeStakingKeyPair generates a self-signed TLS key/cert pair to use in node staking. The key and files will be placed at [keyPath] and [certPath], respectively. If there is already a file at [keyPath], returns nil.

func LoadTLSCertFromBytes

func LoadTLSCertFromBytes(keyBytes, certBytes []byte) (*ctls.Certificate, error)

func LoadTLSCertFromFiles

func LoadTLSCertFromFiles(keyPath, certPath string) (*ctls.Certificate, error)

func NewCertAndKeyBytes

func NewCertAndKeyBytes() ([]byte, []byte, error)

Creates a new TLS private key / TLS certificate pair. Returns the PEM byte representations of both.

func NewCertAndKeyBytesFromKey

func NewCertAndKeyBytesFromKey(key *ecdsa.PrivateKey) ([]byte, []byte, error)

NewCertAndKeyBytesFromKey creates a TLS cert from an existing ECDSA P-256 private key. This allows deterministic NodeID generation from a seed. IMPORTANT: Uses deterministic signing for reproducible certificates.

func NewTLSCert

func NewTLSCert() (*ctls.Certificate, error)

func ValidateRSAPublicKeyIsWellFormed

func ValidateRSAPublicKeyIsWellFormed(pub *rsa.PublicKey) error

ValidateRSAPublicKeyIsWellFormed validates the given RSA public key

Types

type Certificate

type Certificate = ids.Certificate

Certificate is an alias to ids.Certificate

func ParseCertificate

func ParseCertificate(bytes []byte) (*Certificate, error)

ParseCertificate parses a single certificate from the given ASN.1.

This function does not validate that the certificate is valid to be used against normal TLS implementations.

Ref: https://github.com/golang/go/blob/go1.19.12/src/crypto/x509/parser.go#L789-L968

Jump to

Keyboard shortcuts

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