x509view

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 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

Overview

Package x509view decodes one certificate for people (PRD-012, ENH-003): every field of the X.509 document and every extension, in the order an engineer reads them, with the public key's and the signature's classical strength and post-quantum status. It decodes the DER the scanner kept; nothing is stored. Every value comes from the certificate, which an attacker may have chosen: callers render it as text only.

Index

Constants

View Source
const MaxDER = 64 << 10

MaxDER bounds the certificate this package decodes: a real one is a few kilobytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ext

type Ext struct {
	OID      string   `json:"oid"`
	Name     string   `json:"name"`
	Critical bool     `json:"critical"`
	Values   []string `json:"values,omitempty"`
	Hex      string   `json:"hex,omitempty"`
	Cut      bool     `json:"cut,omitempty"` // Hex shows only the first maxHex bytes
}

Ext is one extension: what it is, whether it is critical, and its value. Values holds the decoded value, one entry per item; an extension this package does not decode has Hex instead.

type NamePart

type NamePart struct {
	Type  string `json:"type"` // CN, O, OU, C, L, ST, or the OID
	Value string `json:"value"`
}

NamePart is one attribute of a distinguished name, in the order the certificate lists them.

type Names

type Names struct {
	DNS       []string `json:"dns,omitempty"`
	IP        []string `json:"ip,omitempty"`
	Email     []string `json:"email,omitempty"`
	URI       []string `json:"uri,omitempty"`
	Wildcards []string `json:"wildcards,omitempty"`
	CNOnly    bool     `json:"cnOnly,omitempty"` // a CN and no subjectAltName: modern clients reject it
}

Names are the subject alternative names, by type.

type PublicKey

type PublicKey struct {
	Algorithm  string        `json:"algorithm"`
	OID        string        `json:"oid"`
	Bits       int           `json:"bits,omitempty"`
	Curve      string        `json:"curve,omitempty"`
	Exponent   int           `json:"exponent,omitempty"`
	SPKISHA256 string        `json:"spkiSha256"`
	Strength   algo.Strength `json:"strength"`
	PQC        string        `json:"pqc,omitempty"`
}

PublicKey is the subject's key with its strengths.

type Signature

type Signature struct {
	Algorithm string        `json:"algorithm"`
	OID       string        `json:"oid"`
	Params    string        `json:"params,omitempty"` // RSASSA-PSS parameters in words
	Strength  algo.Strength `json:"strength"`
	PQC       string        `json:"pqc,omitempty"`
}

Signature is the issuer's signature on the certificate.

type View

type View struct {
	Version      int        `json:"version"`
	Serial       string     `json:"serial"`
	Subject      string     `json:"subject"`
	SubjectParts []NamePart `json:"subjectParts"`
	Issuer       string     `json:"issuer"`
	IssuerParts  []NamePart `json:"issuerParts"`
	NotBefore    time.Time  `json:"notBefore"`
	NotAfter     time.Time  `json:"notAfter"`
	LifetimeDays int        `json:"lifetimeDays"`
	Validation   string     `json:"validation,omitempty"` // DV, OV, IV, EV from the CA/Browser Forum policy
	IsCA         bool       `json:"isCa"`
	SelfSigned   bool       `json:"selfSigned"`
	Names        Names      `json:"names"`
	PublicKey    PublicKey  `json:"publicKey"`
	Signature    Signature  `json:"signature"`
	Extensions   []Ext      `json:"extensions"`
	SHA256       string     `json:"sha256"`
	SHA1         string     `json:"sha1"` // an identifier only
	PEM          string     `json:"pem"`
}

View is one certificate, decoded.

func Decode

func Decode(der []byte, issuer *x509.Certificate) (*View, error)

Decode decodes a certificate. issuer, when known, is the certificate that signed it; its key rates the signature (a self-signed certificate is its own issuer).

func DecodeBase64

func DecodeBase64(b64 string, issuer *x509.Certificate) (*View, error)

DecodeBase64 decodes the base64 DER a scan report keeps.

Jump to

Keyboard shortcuts

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