@@ -48,7 +48,7 @@ func (r *secureRequest) SetMessage(request protocol.Request) (err error) {
48
48
j , err := request .JSON ()
49
49
if err != nil {
50
50
protocolErrorCtr .Inc ()
51
- err = fmt .Errorf ("Could not JSON encode reply message to store it in the Secure Request: %s" , err . Error () )
51
+ err = fmt .Errorf ("Could not JSON encode reply message to store it in the Secure Request: %s" , err )
52
52
return
53
53
}
54
54
@@ -59,7 +59,7 @@ func (r *secureRequest) SetMessage(request protocol.Request) (err error) {
59
59
60
60
signature , err = r .signString ([]byte (j ))
61
61
if err != nil {
62
- err = fmt .Errorf ("Could not sign message string: %s" , err . Error () )
62
+ err = fmt .Errorf ("Could not sign message string: %s" , err )
63
63
return
64
64
}
65
65
r .Signature = base64 .StdEncoding .EncodeToString (signature )
@@ -93,7 +93,7 @@ func (r *secureRequest) Valid() bool {
93
93
94
94
cachedpath , err := r .cacheClientCert ()
95
95
if err != nil {
96
- log .Errorf ("Could not cache Client Certificate: %s" , err . Error () )
96
+ log .Errorf ("Could not cache Client Certificate: %s" , err )
97
97
protocolErrorCtr .Inc ()
98
98
return false
99
99
}
@@ -132,14 +132,14 @@ func (r *secureRequest) JSON() (body string, err error) {
132
132
j , err := json .Marshal (r )
133
133
if err != nil {
134
134
protocolErrorCtr .Inc ()
135
- err = fmt .Errorf ("Could not JSON Marshal: %s" , err . Error () )
135
+ err = fmt .Errorf ("Could not JSON Marshal: %s" , err )
136
136
return
137
137
}
138
138
139
139
body = string (j )
140
140
141
141
if err = r .IsValidJSON (body ); err != nil {
142
- err = fmt .Errorf ("JSON produced from the SecureRequest does not pass validation: %s" , err . Error () )
142
+ err = fmt .Errorf ("JSON produced from the SecureRequest does not pass validation: %s" , err )
143
143
return
144
144
}
145
145
@@ -156,7 +156,7 @@ func (r *secureRequest) IsValidJSON(data string) (err error) {
156
156
_ , errors , err := schemas .Validate (schemas .SecureRequestV1 , data )
157
157
if err != nil {
158
158
protocolErrorCtr .Inc ()
159
- err = fmt .Errorf ("Could not validate SecureRequest JSON data: %s" , err . Error () )
159
+ err = fmt .Errorf ("Could not validate SecureRequest JSON data: %s" , err )
160
160
return
161
161
}
162
162
@@ -205,14 +205,14 @@ func (r *secureRequest) matchAnyRegex(str []byte, regex []string) bool {
205
205
func (r * secureRequest ) cacheClientCert () (string , error ) {
206
206
req , err := NewRequestFromSecureRequest (r )
207
207
if err != nil {
208
- log .Errorf ("Could not create Request to validate Secure Request with: %s" , err . Error () )
208
+ log .Errorf ("Could not create Request to validate Secure Request with: %s" , err )
209
209
protocolErrorCtr .Inc ()
210
210
return "" , err
211
211
}
212
212
213
213
certname , err := r .requestCallerCertname (req .CallerID ())
214
214
if err != nil {
215
- log .Errorf ("Could not extract certname from caller: %s" , err . Error () )
215
+ log .Errorf ("Could not extract certname from caller: %s" , err )
216
216
protocolErrorCtr .Inc ()
217
217
return "" , err
218
218
}
@@ -230,7 +230,7 @@ func (r *secureRequest) cacheClientCert() (string, error) {
230
230
err = ioutil .WriteFile (certfile , []byte (r .PublicCertificate ), os .FileMode (int (0644 )))
231
231
if err != nil {
232
232
protocolErrorCtr .Inc ()
233
- return "" , fmt .Errorf ("Could not cache client public certificate: %s" , err . Error () )
233
+ return "" , fmt .Errorf ("Could not cache client public certificate: %s" , err )
234
234
}
235
235
236
236
return certfile , nil
@@ -263,28 +263,28 @@ func (r *secureRequest) shouldCacheClientCert(name string) bool {
263
263
func (r * secureRequest ) verifyCert (certpem []byte , name string ) bool {
264
264
capem , err := ioutil .ReadFile (r .caPath )
265
265
if err != nil {
266
- log .Errorf ("Could not read CA '%s': %s" , r .caPath , err . Error () )
266
+ log .Errorf ("Could not read CA '%s': %s" , r .caPath , err )
267
267
protocolErrorCtr .Inc ()
268
268
return false
269
269
}
270
270
271
271
roots := x509 .NewCertPool ()
272
272
if ! roots .AppendCertsFromPEM (capem ) {
273
- log .Warnf ("Could not use CA '%s' as PEM data: %s" , r .caPath , err . Error () )
273
+ log .Warnf ("Could not use CA '%s' as PEM data: %s" , r .caPath , err )
274
274
protocolErrorCtr .Inc ()
275
275
return false
276
276
}
277
277
278
278
block , _ := pem .Decode (certpem )
279
279
if block == nil {
280
- log .Warnf ("Could not decode certificate '%s' PEM data: %s" , name , err . Error () )
280
+ log .Warnf ("Could not decode certificate '%s' PEM data: %s" , name , err )
281
281
protocolErrorCtr .Inc ()
282
282
return false
283
283
}
284
284
285
285
cert , err := x509 .ParseCertificate (block .Bytes )
286
286
if err != nil {
287
- log .Warnf ("Could not parse certificate '%s': %s" , name , err . Error () )
287
+ log .Warnf ("Could not parse certificate '%s': %s" , name , err )
288
288
protocolErrorCtr .Inc ()
289
289
return false
290
290
}
@@ -300,7 +300,7 @@ func (r *secureRequest) verifyCert(certpem []byte, name string) bool {
300
300
_ , err = cert .Verify (opts )
301
301
if err != nil {
302
302
invalidCertificateCtr .Inc ()
303
- log .Warnf ("Certificate does not pass verification as '%s': %s" , name , err . Error () )
303
+ log .Warnf ("Certificate does not pass verification as '%s': %s" , name , err )
304
304
return false
305
305
}
306
306
@@ -327,7 +327,7 @@ func (r *secureRequest) decodePEM(certpath string) (pb *pem.Block, err error) {
327
327
keydat , err := readFile (certpath )
328
328
if err != nil {
329
329
protocolErrorCtr .Inc ()
330
- return pb , fmt .Errorf ("Could not read PEM data from %s: %s" , certpath , err . Error () )
330
+ return pb , fmt .Errorf ("Could not read PEM data from %s: %s" , certpath , err )
331
331
}
332
332
333
333
pb , _ = pem .Decode (keydat )
@@ -348,7 +348,7 @@ func (r *secureRequest) signString(str []byte) (signature []byte, err error) {
348
348
pk , err := x509 .ParsePKCS1PrivateKey (pkpem .Bytes )
349
349
if err != nil {
350
350
protocolErrorCtr .Inc ()
351
- err = fmt .Errorf ("Could not parse private key PEM data: %s" , err . Error () )
351
+ err = fmt .Errorf ("Could not parse private key PEM data: %s" , err )
352
352
return
353
353
}
354
354
@@ -357,7 +357,7 @@ func (r *secureRequest) signString(str []byte) (signature []byte, err error) {
357
357
signature , err = rsa .SignPKCS1v15 (rng , pk , crypto .SHA256 , hashed [:])
358
358
if err != nil {
359
359
protocolErrorCtr .Inc ()
360
- err = fmt .Errorf ("Could not sign message: %s" , err . Error () )
360
+ err = fmt .Errorf ("Could not sign message: %s" , err )
361
361
}
362
362
363
363
return
@@ -367,14 +367,14 @@ func (r *secureRequest) verifySignature(str []byte, sig []byte, pubkeyPath strin
367
367
pkpem , err := r .decodePEM (pubkeyPath )
368
368
if err != nil {
369
369
protocolErrorCtr .Inc ()
370
- log .Errorf ("Could not decode PEM data in public key %s: %s" , pubkeyPath , err . Error () )
370
+ log .Errorf ("Could not decode PEM data in public key %s: %s" , pubkeyPath , err )
371
371
return false
372
372
}
373
373
374
374
cert , err := x509 .ParseCertificate (pkpem .Bytes )
375
375
if err != nil {
376
376
protocolErrorCtr .Inc ()
377
- log .Errorf ("Could not parse decoded PEM data for public key %s: %s" , pubkeyPath , err . Error () )
377
+ log .Errorf ("Could not parse decoded PEM data for public key %s: %s" , pubkeyPath , err )
378
378
return false
379
379
}
380
380
@@ -384,13 +384,13 @@ func (r *secureRequest) verifySignature(str []byte, sig []byte, pubkeyPath strin
384
384
decodedsig , err := base64 .StdEncoding .DecodeString (string (sig ))
385
385
if err != nil {
386
386
protocolErrorCtr .Inc ()
387
- log .Errorf ("Could not decode signature base64 encoding: %s" , err . Error () )
387
+ log .Errorf ("Could not decode signature base64 encoding: %s" , err )
388
388
return false
389
389
}
390
390
391
391
err = rsa .VerifyPKCS1v15 (rsaPublicKey , crypto .SHA256 , hashed [:], decodedsig )
392
392
if err != nil {
393
- log .Errorf ("Verification using %s failed: %s" , pubkeyPath , err . Error () )
393
+ log .Errorf ("Verification using %s failed: %s" , pubkeyPath , err )
394
394
return false
395
395
}
396
396
@@ -401,7 +401,7 @@ func readFile(path string) (cert []byte, err error) {
401
401
cert , err = ioutil .ReadFile (path )
402
402
if err != nil {
403
403
protocolErrorCtr .Inc ()
404
- err = fmt .Errorf ("Could not read file %s: %s" , path , err . Error () )
404
+ err = fmt .Errorf ("Could not read file %s: %s" , path , err )
405
405
}
406
406
407
407
return
0 commit comments