-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4921604
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Documentation | ||
|
||
* [OpenSSL Index Format](https://pki-tutorial.readthedocs.io/en/latest/cadb.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/encbladexp/expired_certificate_check | ||
|
||
go 1.23.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |