in src/CsrValidation/csharp/revocationExample/Program.cs [36:110]
static void Main(string[] args)
{
// If scenario requires the use of a proxy with authentication then you need to supply your own WebProxy like the following.
string proxyHost = "http://localhost";
string proxyPort = "8888";
string proxyUser = "proxyuser";
string proxyPass = "proxypass";
var proxy = new WebProxy()
{
Address = new Uri($"{proxyHost}:{proxyPort}"),
UseDefaultCredentials = false,
// *** These creds are given to the proxy server, not the web server ***
Credentials = new NetworkCredential(
userName: proxyUser,
password: proxyPass)
};
// Uncomment the following line to use a proxy
//System.Net.WebRequest.DefaultWebProxy = proxy;
// Populate properties dictionary with properties needed for API.
// This example uses a simple Java like properties file to pass in the settings to maintain consistency.
var configProperties = SimpleIniParser.Parse("com.microsoft.intune.props");
var trace = new TraceSource("log");
var transactionId = Guid.NewGuid(); // A GUID that will uniquley identify the entire transaction to allow for log correlation accross Validate and Notification calls.
// Create CARevocationRequest Client
var revocationClient = new IntuneRevocationClient(
configProperties,
trace: trace
);
// Set Download Parameters
int maxRequests = 100; // Maximum number of Revocation requests to download at a time
string issuerName = null; // Optional Parameter: Set this value if you want to filter
// the request to only download request matching this Issuer Name
// Download CARevocationRequests from Intune
List<CARevocationRequest> caRevocationRequests = (revocationClient.DownloadCARevocationRequestsAsync(transactionId.ToString(), maxRequests, issuerName)).Result;
Console.WriteLine($"Downloaded {caRevocationRequests.Count} number of Revocation requests from Intune.");
// Process CARevocationRequest List
List<CARevocationResult> revocationResults = new List<CARevocationResult>();
foreach (CARevocationRequest request in caRevocationRequests)
{
// Revoke the certificate
RevokeCertificate(
request.SerialNumber,
out bool succeeded,
out CARequestErrorCode errorCode,
out string errorMessage);
// Add result to list
revocationResults.Add(new CARevocationResult(request.RequestContext, succeeded, errorCode, errorMessage));
}
if (revocationResults.Count > 0)
{
try
{
Console.WriteLine($"Uploading {revocationResults.Count} Revocation Results to Intune.");
// Upload Results to Intune
(revocationClient.UploadRevocationResultsAsync(transactionId.ToString(), revocationResults)).Wait();
}
catch(AggregateException e)
{
Console.WriteLine($"Upload of results to to Intune Failed. Exception: {e.InnerException}");
}
}
}