Skip to content

Instantly share code, notes, and snippets.

@sdurandeu
Created June 6, 2014 20:03
Show Gist options
  • Select an option

  • Save sdurandeu/4234fe904cfea9e39ec8 to your computer and use it in GitHub Desktop.

Select an option

Save sdurandeu/4234fe904cfea9e39ec8 to your computer and use it in GitHub Desktop.
Request with Client Certificate
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);
var cert = store.Certificates.Find(X509FindType.FindByThumbprint, "ff9afddf408ccd62a5dc83aacc48f8432ab7c86c", false)[0];
var messageHandler = new WebRequestHandler();
messageHandler.ClientCertificates.Add(cert);
messageHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
HttpClient httpClient = new HttpClient(messageHandler);
var result = httpClient.GetAsync("https://clientcertificatetesting.azurewebsites.net/").Result;
store.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment