Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class X509Authentication : IClientAuthenticator
- {
- protected readonly X509Certificate2 Certificate;
- public X509Authentication(X509Certificate2 certificate)
- {
- if (certificate == null) throw new ArgumentNullException("certificate");
- Certificate = certificate;
- }
- public HttpClient GenerateClient()
- {
- var clientHandler = new WebRequestHandler();
- clientHandler.ClientCertificates.Add(Certificate);
- var request = new HttpClient(clientHandler);
- return request;
- }
- public void Dispose()
- {
- //nothing to do here.
- }
- }
- [TestMethod]
- public void HttpClientCreationIncludesCertificate()
- {
- using (var auth = new X509Authentication(_certificate))
- using (var client = auth.GenerateClient())
- {
- Assert...what? The certificate(s) are not visible here.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement