@@ -136,6 +136,7 @@ func (b *keyfactorBackend) pathFetchCert(ctx context.Context, req *logical.Reque
136
136
// this is basically handled by setting contentType or not.
137
137
// Errors don't cause an immediate exit, because the raw
138
138
// paths still need to return raw output.
139
+
139
140
b .Logger ().Debug ("fetching cert, path = " + req .Path )
140
141
141
142
serial = data .Get ("serial" ).(string )
@@ -485,8 +486,8 @@ func revokeCert(ctx context.Context, b *keyfactorBackend, req *logical.Request,
485
486
"Comment": "%s",
486
487
"EffectiveDate": "%s"},
487
488
"CollectionId": 0
488
- }` , keyfactorId , "via HashiCorp Vault" , time .Now ().UTC (). String ( ))
489
- // b.Logger().Debug("Sending revocation request. payload = " + payload)
489
+ }` , keyfactorId , "via HashiCorp Vault" , time .Now ().Format ( time . RFC3339 ))
490
+ b .Logger ().Debug ("Sending revocation request. payload = " + payload )
490
491
httpReq , _ := http .NewRequest ("POST" , url , strings .NewReader (payload ))
491
492
492
493
httpReq .Header .Add ("x-keyfactor-requested-with" , "APIClient" )
@@ -498,10 +499,13 @@ func revokeCert(ctx context.Context, b *keyfactorBackend, req *logical.Request,
498
499
b .Logger ().Error ("Revoke failed: {{err}}" , err )
499
500
return nil , err
500
501
}
501
- if res .StatusCode != 204 {
502
- r , _ := io .ReadAll (res .Body )
502
+ r , _ := io .ReadAll (res .Body )
503
+
504
+ b .Logger ().Debug ("response received. Status code " + fmt .Sprint (res .StatusCode ) + " response body: \n " + string (r [:]))
505
+ if res .StatusCode != 204 && res .StatusCode != 200 {
506
+ // r, _ := io.ReadAll(res.Body)
503
507
b .Logger ().Info ("revocation failed: server returned" + fmt .Sprint (res .StatusCode ))
504
- b .Logger ().Info ("error response = " + fmt . Sprint ( r ))
508
+ b .Logger ().Info ("error response = " + string ( r [:] ))
505
509
return nil , fmt .Errorf ("revocation failed: server returned %s\n " , res .Status )
506
510
}
507
511
@@ -548,8 +552,8 @@ func revokeCert(ctx context.Context, b *keyfactorBackend, req *logical.Request,
548
552
}
549
553
return logical .ErrorResponse (fmt .Sprintf ("certificate with serial %s not found" , serial )), nil
550
554
}
551
- b .Logger ().Info ("certEntry key = " + certEntry .Key )
552
- b .Logger ().Info ("certEntry value = " + string (certEntry .Value ))
555
+ b .Logger ().Debug ("certEntry key = " + certEntry .Key )
556
+ b .Logger ().Debug ("certEntry value = " + string (certEntry .Value ))
553
557
554
558
currTime := time .Now ()
555
559
revInfo .CertificateBytes = certEntry .Value
@@ -565,7 +569,6 @@ func revokeCert(ctx context.Context, b *keyfactorBackend, req *logical.Request,
565
569
if err != nil {
566
570
return nil , fmt .Errorf ("error saving revoked certificate to new location" )
567
571
}
568
-
569
572
}
570
573
571
574
resp := & logical.Response {
@@ -574,7 +577,7 @@ func revokeCert(ctx context.Context, b *keyfactorBackend, req *logical.Request,
574
577
},
575
578
}
576
579
if ! revInfo .RevocationTimeUTC .IsZero () {
577
- resp .Data ["revocation_time_rfc3339" ] = revInfo .RevocationTimeUTC .Format (time .RFC3339Nano )
580
+ resp .Data ["revocation_time_rfc3339" ] = revInfo .RevocationTimeUTC .Format (time .RFC3339 )
578
581
}
579
582
return resp , nil
580
583
}
0 commit comments