testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package testutil holds helpers that tests of several packages share. It is imported by tests only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenSSL

func OpenSSL(tb testing.TB) string

OpenSSL returns the openssl binary for cross-checks. Missing or too old: skipped locally, fatal in CI – the cross-check must not disappear silently.

Types

type PKCS12

type PKCS12 struct {
	Certs  []*x509.Certificate
	KeyDER []byte // PKCS#8, as OpenSSL decrypted it
	Text   string // the whole output, for the stable facts of -info
}

PKCS12 is what `openssl pkcs12 -nodes` read from a file: the certificates and the decrypted key as PEM blocks, parsed with crypto/x509. Tests compare these with the originals instead of OpenSSL's text, whose format differs between versions (3.0 prints "subject=CN = x", 3.5 "subject=CN=x").

func OpenSSLPKCS12

func OpenSSLPKCS12(tb testing.TB, file, password string, info bool) (*PKCS12, error)

OpenSSLPKCS12 opens file with the password (written to a temp file, never on the command line) and returns what OpenSSL read. info adds -info (MAC and encryption facts in Text). An error carries OpenSSL's output.

func (*PKCS12) InfoProblems

func (p *PKCS12) InfoProblems(facts ...string) []string

InfoProblems checks the stable facts of -info: the names of algorithms and numbers, never the layout around them.

func (*PKCS12) Problems

func (p *PKCS12) Problems(leaf *x509.Certificate, chain []*x509.Certificate, friendlyName string) []string

Problems compares what OpenSSL read with the originals: exactly the leaf and the chain (byte for byte, order free), a key that belongs to the leaf, and the friendly name. It names each missing or wrong part.

Jump to

Keyboard shortcuts

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