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

Check for base64 when reading a PKCS12 certificate file #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion Rubeus/lib/Ask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@ public class Ask
// with private key otherwise use users certificate store along with any smartcard that maybe present.
public static X509Certificate2 FindCertificate(string certificate, string storePassword) {

if (File.Exists(certificate)) {
if (File.Exists(certificate))
{

string certificateData = File.ReadAllText(certificate);

//Check if the file content is actually base64 encoded
if (Helpers.IsBase64String(certificateData))
return new X509Certificate2(Convert.FromBase64String(certificateData), storePassword);

return new X509Certificate2(certificate, storePassword);

} else {

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
Expand Down