diff --git a/README.md b/README.md new file mode 100644 index 0000000..adc2f4d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Documentation + +* [OpenSSL Index Format](https://pki-tutorial.readthedocs.io/en/latest/cadb.html) diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..196ea3b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/encbladexp/expired_certificate_check + +go 1.23.1 diff --git a/main.go b/main.go new file mode 100644 index 0000000..082034d --- /dev/null +++ b/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "encoding/csv" + "fmt" + "os" +) + +type Certificate struct { + Status string + Expired string + Revoked string + Serial string + Filename string + CN string +} + +type Certificates struct { + Certificates []Certificate +} + +func (c *Certificates) process_line(line []string) { + cert := Certificate{ + line[0], + line[1], + line[2], + line[3], + line[4], + line[5], + } + c.Certificates = append(c.Certificates, cert) +} + +const FILENAME = "index.txt" + +func main() { + file, err := os.Open(FILENAME) + if err != nil { + panic(err) + } + defer file.Close() + csvreader := csv.NewReader(file) + csvreader.Comma = '\t' + lines, err := csvreader.ReadAll() + if err != nil { + panic(err) + } + cert_store := Certificates{} + for _, line := range lines { + cert_store.process_line(line) + } + fmt.Println(cert_store.Certificates) +}