|
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Security.Cryptography.X509Certificates;
namespace DevAge.ServiceModel
{
/// <summary>
/// Client Proxy configurator
/// </summary>
public static class Proxy<T> where T : class
{
/// <summary>
/// Configure the specified client proxy using the certificate file specified in the configuration file
/// </summary>
public static void Configure(ClientBase<T> client)
{
//Check if there is a valid configuration section
Configuration.Section section = Configuration.Section.GetSection();
if (section == null || section.EndPoints == null)
return;
//Check if there is a valid configuration for this service
Configuration.EndPointElement element = section.EndPoints.GetElementByKey(client.Endpoint.Contract.ConfigurationName);
if (element == null)
return;
X509Certificate2 certificate = element.GetClientCertificate();
if (certificate != null)
client.ClientCredentials.ClientCertificate.Certificate = certificate;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.