forked from liamjbennett/sous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (33 loc) · 739 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"bytes"
"crypto/x509"
"encoding/pem"
"log"
"os"
"github.com/docopt/docopt-go"
)
func main() {
log.SetFlags(log.Flags() | log.Lshortfile)
parsed, err := docopt.Parse(`Usage: cert_san <cert-path>`, nil, true, "", false)
if err != nil {
log.Fatal(err)
}
certPath := parsed["<cert-path>"].(string)
certFile, err := os.Open(certPath)
if err != nil {
log.Fatal(err)
}
certBuf := bytes.Buffer{}
_, err = certBuf.ReadFrom(certFile)
if err != nil {
log.Fatal(err)
}
log.Print("\n", certBuf.String())
block, _ := pem.Decode(certBuf.Bytes())
cert, err := x509.ParseCertificate(block.Bytes)
if err != nil {
log.Fatal(err)
}
log.Printf("Cert good for addresses: %+v", cert.IPAddresses)
}