Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print exceptions on policy decrypt errors #41

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading