Debian Codegraph @

fakeca/README.md

raw symbols SCIP
1 # fakeca [![PkgGoDev](https://pkg.go.dev/badge/github.com/github/smimesign/fakeca?tab=doc)](https://pkg.go.dev/github.com/github/smimesign/fakeca?tab=doc)
2
3 This is a package for creating fake certificate authorities for test fixtures.
4
5 ## Example
6
7 ```go
8 package main
9
10 import (
11 "crypto/x509/pkix"
12
13 "github.com/github/smimesign/fakeca"
14 )
15
16 func main() {
17 // Change defaults for cert subjects.
18 fakeca.DefaultProvince = []string{"CO"}
19 fakeca.DefaultLocality = []string{"Denver"}
20
21 // Create a root CA.
22 root := fakeca.New(fakeca.IsCA, fakeca.Subject(pkix.Name{
23 CommonName: "root.myorg.com",
24 }))
25
26 // Create an intermediate CA under the root.
27 intermediate := root.Issue(fakeca.IsCA, fakeca.Subject(pkix.Name{
28 CommonName: "intermediate.myorg.com",
29 }))
30
31 // Create a leaf certificate under the intermediate.
32 leaf := intermediate.Issue(fakeca.Subject(pkix.Name{
33 CommonName: "leaf.myorg.com",
34 }))
35
36 // Get PFX (PKCS12) blob containing certificate and encrypted private key.
37 leafPFX := leaf.PFX("pa55w0rd")
38
39 // Get an *x509.CertPool containing certificate chain from CA to leaf for use
40 // with Go's TLS libraries.
41 leafPool := leaf.ChainPool()
42 }
43
44 ```