redistls

package
v0.54.0 Latest Latest
Warning

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

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

Documentation

Overview

Package redistls provides TLS fixtures for Redis tests: a TLS-only in-memory Redis endpoint verified by a test CA, and on-disk certificates for running a real Redis server with TLS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CACertPEM

func CACertPEM(t *testing.T) []byte

CACertPEM returns a PEM-encoded CA certificate for tests that only need valid certificate bytes.

func Start

func Start(t *testing.T) (*miniredis.Miniredis, string)

Start runs a TLS-only Redis endpoint and returns it together with the path of the CA certificate that verifies it.

func StartWithCertificates

func StartWithCertificates(t *testing.T, certs *Certificates) *miniredis.Miniredis

StartWithCertificates runs a TLS-only Redis endpoint that presents the server certificate from certs.

Types

type Certificates

type Certificates struct {
	// CACertFile is the CA a client must trust to complete the handshake.
	CACertFile string
	// ServerCertFile and ServerKeyFile are the server's certificate and key.
	ServerCertFile string
	ServerKeyFile  string
	// contains filtered or unexported fields
}

Certificates are PEM files for a private CA and a server certificate signed by it. The server certificate is valid only for the IP address 127.0.0.1 (no DNS names), so dialing the server as "localhost" must fail hostname verification.

func NewCertificates

func NewCertificates(dir string) (*Certificates, error)

NewCertificates generates a private CA and a 127.0.0.1 server certificate and writes them to dir as ca.crt, server.crt and server.key (mode 0600).

Jump to

Keyboard shortcuts

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