A library to build custom search tools for X.509 certificates
Go to file
Preston Locke a2cfdeabbd
Run DERFilter before parsing DER into certificate (#4)
Fixes #3
2024-10-30 16:01:36 -05:00
.github/workflows Fix golangci-lint version number 2024-10-29 17:09:46 -05:00
staticctapi Initial commit 2024-10-29 16:44:02 -05:00
.gitignore Initial commit 2024-10-29 16:44:02 -05:00
.golangci.yaml Run DERFilter before parsing DER into certificate (#4) 2024-10-30 16:01:36 -05:00
CODE_OF_CONDUCT.md Initial commit 2024-10-29 16:44:02 -05:00
LICENSE Initial commit 2024-10-29 16:44:02 -05:00
README.md Add some comments to the example in README.md 2024-10-29 17:23:44 -05:00
cache.go Initial commit 2024-10-29 16:44:02 -05:00
go.mod Upgrade to Go 1.23 2024-10-29 16:49:11 -05:00
go.sum Initial commit 2024-10-29 16:44:02 -05:00
search.go Run DERFilter before parsing DER into certificate (#4) 2024-10-30 16:01:36 -05:00

README.md

x509search

A library to build custom search tools for X.509 certificates

Usage

Here's an example of using x509search to scan through a tiled CT log for precertificates issued by Let's Encrypt:

package main

import (
	"context"
	"crypto/x509"
	"fmt"
	"os"
	"time"

	"github.com/letsencrypt/x509search"
	"github.com/letsencrypt/x509search/staticctapi"
)

func main() {
	rome2025h1, err := staticctapi.NewLog("https://rome2025h1.fly.storage.tigris.dev/")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	now := time.Now()
	search := x509search.Search{
		// Filter by the Organization Name of the certificate issuer
		Filter: func(cert *x509.Certificate) bool {
			if len(cert.Issuer.Organization) != 1 {
				return false
			}
			return cert.Issuer.Organization[0] == "Let's Encrypt"
		},
		// Print out the issuer and subject info every time there's a match
		MatchCallback: func(cert *x509.Certificate) {
			fmt.Printf("Issuer: %s Subject: %s\n", cert.Issuer.String(), cert.Subject.String())
		},
		// Configure a single data source: the Rome2025h1 tiled log
		DataSources: []x509search.Sourcer{
			staticctapi.DataSource{
				Log:                    rome2025h1,
				IncludePrecertificates: true,
				IncludeCertificates:    false,
				StartTimeInclusive:     now.Add(-3*time.Hour - 1*time.Minute),
				EndTimeInclusive:       now.Add(-3 * time.Hour),
				MaxConnections:         10,
			},
		},
	}

	search.Execute(context.Background())
}