Skip to content

Commit

Permalink
Merge pull request #41 from Mayyhem/handle-policy-decrypt-errors
Browse files Browse the repository at this point in the history
Print exceptions on policy decrypt errors
  • Loading branch information
Mayyhem authored Sep 16, 2023
2 parents ba23103 + f595de0 commit 371bd88
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/MgmtPointMessaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public static string DecryptPolicyBody(byte[] policyDownloadResponseBytes, Messa
string decryptedPolicyBody = Encoding.ASCII.GetString(pkcs7EnvelopedCms.ContentInfo.Content).Replace("\0", string.Empty);
return decryptedPolicyBody;
}
catch (Exception)
catch (Exception ex)
{
Console.WriteLine("[!] Could not decrypt the secret policy");
Console.WriteLine($"[!] An exception occurred while trying to decrypt policy response: {ex.Message}");
return null;
}
}
Expand Down Expand Up @@ -202,9 +202,9 @@ public static async void GetSecretsFromPolicy(PolicyAssignment policyAssignment,
byte[] policyDownloadResponseBytes = await policyDownloadResponse.Content.ReadAsByteArrayAsync();
Console.WriteLine($"[+] Received encoded response from server for policy {policyAssignment.Policy.Id}");
}
catch
catch (Exception ex)
{
Console.WriteLine($" Failed to download :/");
Console.WriteLine($"[!] An exception occurred while trying to download policy: {ex.Message}");
return;
}
if (policyDownloadResponse != null)
Expand All @@ -214,9 +214,9 @@ public static async void GetSecretsFromPolicy(PolicyAssignment policyAssignment,
{
decryptedPolicyBody = DecryptPolicyBody(policyDownloadResponseBytes, encryptionCertificate);
}
catch
catch (Exception ex)
{
Console.WriteLine($"[-] Error while trying to decrypt policy response :/...");
Console.WriteLine($"[!] An exception occurred while trying to decrypt policy response: {ex.Message}");
}
}
if (decryptedPolicyBody != null)
Expand Down

0 comments on commit 371bd88

Please sign in to comment.