Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created March 30, 2013 09:15
Show Gist options
  • Save wullemsb/5276046 to your computer and use it in GitHub Desktop.
Save wullemsb/5276046 to your computer and use it in GitHub Desktop.
Add a certificate property to a DataServiceContext
namespace ODataSample
{
public partial class Entities
{
private X509Certificate _clientCertificate = null;
public X509Certificate ClientCertificate
{
get
{
return _clientCertificate;
}
set
{
if (value == null)
{
if (_clientCertificate != null)
this.SendingRequest -= OnSendingRequest_AddCertificate;
}
else
{
if (_clientCertificate == null)
this.SendingRequest += OnSendingRequest_AddCertificate;
}
}
_clientCertificate = value;
}
private void OnSendingRequest_AddCertificate(object sender, SendingRequestEventArgs args)
{
if (null != ClientCertificate)
(args.Request as HttpWebRequest).ClientCertificates.Add(ClientCertificate);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment