File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed
Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,36 @@ func downloadMozillaRemovedCACertsList() ([]removedCertificate, error) {
6060
6161 removedCerts := make ([]removedCertificate , len (csvLines ))
6262 for i , csvLine := range csvLines {
63- removedCerts [i ] = removedCertificate {
64- // From the CSV format that Mozilla publishes, the 8th column (id 7) is the fingerprint and the 23rd column
65- // (id 22) is the comment.
66- Fingerprint : csvLine [7 ],
67- Comments : csvLine [22 ],
63+ // Skip the header row
64+ if i == 0 {
65+ continue
66+ }
67+
68+ // Find column indices by their names from the header
69+ var fingerprint , comments int
70+ if i == 1 {
71+ fingerprint = - 1
72+ comments = - 1
73+ for idx , header := range csvLines [0 ] {
74+ switch header {
75+ case "SHA-256 Fingerprint" :
76+ fingerprint = idx
77+ case "Comments" :
78+ comments = idx
79+ }
80+ }
81+
82+ if fingerprint == - 1 {
83+ return nil , fmt .Errorf ("required column 'SHA-256 Fingerprint' not found in CSV header" )
84+ }
85+ if comments == - 1 {
86+ return nil , fmt .Errorf ("required column 'Comments' not found in CSV header" )
87+ }
88+ }
89+
90+ removedCerts [i - 1 ] = removedCertificate {
91+ Fingerprint : csvLine [fingerprint ],
92+ Comments : csvLine [comments ],
6893 }
6994 }
7095 return removedCerts , nil
You can’t perform that action at this time.
0 commit comments