@@ -3,6 +3,7 @@ package auth
33import (
44 "crypto/x509"
55 "crypto/x509/pkix"
6+ "fmt"
67 "github.com/ARGOeu/argo-api-authn/utils"
78 LOGGER "github.com/sirupsen/logrus"
89 "io/ioutil"
@@ -17,7 +18,7 @@ func CRLCheckRevokedCert(cert *x509.Certificate) error {
1718
1819 var err error
1920 var goMaxP , psi , csi int
20- var crtList * pkix.TBSCertificateList
21+ var crtList pkix.TBSCertificateList
2122 var errChan = make (chan error )
2223 var doneChan = make (chan bool , 1 )
2324
@@ -118,30 +119,37 @@ loop:
118119}
119120
120121// FetchCRL fetches the CRL
121- func FetchCRL (url string ) (* pkix.TBSCertificateList , error ) {
122+ func FetchCRL (url string ) (pkix.TBSCertificateList , error ) {
122123
123124 var err error
124- var crtList * pkix.CertificateList
125125 var resp * http.Response
126126 var crlBytes []byte
127127
128+ var crtList = & pkix.CertificateList {}
129+
128130 // initialize the client and perform a get request to grab the crl
129- client := & http.Client {Timeout : time .Duration (60 * time .Second )}
131+ client := & http.Client {Timeout : time .Duration (30 * time .Second )}
130132 if resp , err = client .Get (url ); err != nil {
131- return & crtList .TBSCertList , err
133+ LOGGER .Error (fmt .Errorf ("Request to CRL: %v produced the following error, %v" , url , err .Error ()))
134+ err := fmt .Errorf ("Could not access CRL %v" , url )
135+ return pkix.TBSCertificateList {}, err
132136 }
133137
134138 // read the response
135139 if crlBytes , err = ioutil .ReadAll (resp .Body ); err != nil {
136- return & crtList .TBSCertList , err
140+ err := fmt .Errorf ("Reading CRL data: %v produced the following error, %v" , url , err .Error ())
141+ LOGGER .Error (err )
142+ return pkix.TBSCertificateList {}, err
137143 }
138144
139145 defer resp .Body .Close ()
140146
141147 // create the crl from the byte slice
142148 if crtList , err = x509 .ParseCRL (crlBytes ); err != nil {
143- return & crtList .TBSCertList , err
149+ err := fmt .Errorf ("Parsing CRL data: %v produced the following error, %v" , url , err .Error ())
150+ LOGGER .Error (err )
151+ return pkix.TBSCertificateList {}, err
144152 }
145153
146- return & crtList .TBSCertList , err
154+ return crtList .TBSCertList , err
147155}
0 commit comments