Skip to content

Commit

Permalink
Errorfixes (#16)
Browse files Browse the repository at this point in the history
* fixed error handling from Hydrant API changes
* Fixed Enrollment External Validation
  • Loading branch information
fiddlermikey authored Nov 8, 2023
1 parent 73787c6 commit bbadd31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
32 changes: 12 additions & 20 deletions HydrantIdProxy/src/HydrantIdProxy/HydrantIdProxy.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright 2023 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless
// required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
// OR CONDITIONS OF ANY KIND, either express or implied. See the License for
// thespecific language governing permissions and limitations under the
// License.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -179,8 +170,6 @@ public override EnrollmentResult Enroll(ICertificateDataReader certificateDataRe
{
Logger.MethodEntry(ILogExtensions.MethodLogLevel.Debug);
CertRequestResult enrollmentResponse = null;
int timerTries = 0;
Certificate csrTrackingResponse=null;

Certificate csrTrackingResponse=null;

Expand Down Expand Up @@ -210,7 +199,6 @@ public override EnrollmentResult Enroll(ICertificateDataReader certificateDataRe

if (enrollmentResponse?.ErrorReturn?.Status != "Failure")
{
timerTries = +1;
csrTrackingResponse = GetCertificateOnTimer(enrollmentResponse?.RequestStatus?.Id);
}
else
Expand Down Expand Up @@ -251,16 +239,20 @@ await HydrantIdClient.GetSubmitRenewalAsync(certificateId, renewalRequest))

if (enrollmentResponse?.ErrorReturn?.Status != "Failure")
{
timerTries = +1;
if(csrTrackingResponse==null && timerTries>0)
{
return new EnrollmentResult
{
Status = 30, //failure
StatusMessage = $"Certificate may still waiting on Hydrant and is not ready for download"
};
csrTrackingResponse = GetCertificateOnTimer(enrollmentResponse?.RequestStatus?.Id);
}
else
{
return new EnrollmentResult
{
Status = 30, //failure
StatusMessage = $"Enrollment Failed with error {enrollmentResponse?.ErrorReturn?.Error}"
};
}
break;
}


var cert = GetSingleRecord(csrTrackingResponse.Id.ToString());
return _requestManager.GetEnrollmentResult(csrTrackingResponse,cert);
}
Expand Down
11 changes: 1 addition & 10 deletions HydrantIdProxy/src/HydrantIdProxy/RequestManager.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright 2023 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless
// required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
// OR CONDITIONS OF ANY KIND, either express or implied. See the License for
// thespecific language governing permissions and limitations under the
// License.
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -16,9 +7,9 @@
using Keyfactor.HydrantId.Client.Models;
using Keyfactor.HydrantId.Client.Models.Enums;
using Keyfactor.HydrantId.Interfaces;
using Org.BouncyCastle.Pkcs;
using Keyfactor.HydrantId.Exceptions;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Pkcs;

namespace Keyfactor.HydrantId
{
Expand Down

0 comments on commit bbadd31

Please sign in to comment.