Created
March 30, 2013 09:15
-
-
Save wullemsb/5276046 to your computer and use it in GitHub Desktop.
Add a certificate property to a DataServiceContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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