From 4921604283e2b97e98b7888a2b6d6eaf12058659 Mon Sep 17 00:00:00 2001 From: "Stefan J. Betz" Date: Sat, 28 Sep 2024 12:58:45 +0200 Subject: [PATCH] initial commit --- README.md | 3 +++ go.mod | 3 +++ main.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 README.md create mode 100644 go.mod create mode 100644 main.go 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) +}