Initial import.

This commit is contained in:
Kyle Isom
2015-06-10 16:29:52 -07:00
commit 7391da8567
12 changed files with 365 additions and 0 deletions

20
cmd/readchain/README Normal file
View File

@@ -0,0 +1,20 @@
readchain
This is a small utility to read a chain of PEM-encoded X.509 certificates
and print their common names. It was written to quickly see what certificates
were in a bundle.
It is called with the files containing chains to read passed in as an
argument. The program has no knobs or widgets to adjust.
Examples:
$ readchain google.com.pem microsoft.com.pem
[+] google.com.pem:
*.google.com
Google Internet Authority G2
GeoTrust Global CA
[+] microsoft.com.pem:
microsoft.com
MSIT Machine Auth CA 2
Microsoft Internet Authority

40
cmd/readchain/chain.go Normal file
View File

@@ -0,0 +1,40 @@
package main
import (
"crypto/x509"
"encoding/pem"
"flag"
"fmt"
"io/ioutil"
"os"
)
func main() {
flag.Parse()
for _, fileName := range flag.Args() {
data, err := ioutil.ReadFile(fileName)
if err != nil {
fmt.Fprintf(os.Stderr, "[!] %s: %v\n", fileName, err)
continue
}
fmt.Printf("[+] %s:\n", fileName)
rest := data[:]
for {
var p *pem.Block
p, rest = pem.Decode(rest)
if p == nil {
break
}
cert, err := x509.ParseCertificate(p.Bytes)
if err != nil {
fmt.Fprintf(os.Stderr, "[!] %s: %v\n", fileName, err)
break
}
fmt.Printf("\t%+v\n", cert.Subject.CommonName)
}
}
}