Click here to Skip to main content
11,637,176 members (60,259 online)
Click here to Skip to main content
Add your own
alternative version

An easy way to use certificates for WCF security

, 30 Apr 2007 MIT 283.6K 5.4K 128
An easy solution to use certificates on Windows Communication Foundation loading the certificates from files
wcfcertificates.zip
WCFCertificates
Bin
DevAge.ServiceModel.dll
Client
Client.cer
Client.pfx
Client.pvk
Properties
Service References
MathService.map
DevAge.ServiceModel
Configuration
Properties
Documents
Server
App_Code
App_Data
Client.cer
Server.cer
Server.pfx
Server.pvk
Bin
DevAge.ServiceModel.dll
MathService.svc
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Activation;

namespace DevAge.ServiceModel
{

    //ISS .svc example
    //<%@ServiceHost Service="YourCalculatorService"
    //               Factory="DevAge.ServiceModel.CertificateServiceHostFactory"
    //               language=c# Debug="true" %>
    // 
    // For more informations look at:
    // http://msdn2.microsoft.com/en-us/library/aa395224.aspx  "Custom Service Host"

    /// <summary>
    /// The factory class derived from ServiceHostFactory used to create the CertificateServiceHost class.
    /// Useful when hosting the service with IIS where you cannot specify what class to create but you can specify the host factory.
    /// </summary>
    public class CertificateServiceHostFactory : ServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            return new CertificateServiceHost(serviceType, baseAddresses);
        }
    }
}

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.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Davide Icardi
Software Developer
Italy Italy
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150728.1 | Last Updated 30 Apr 2007
Article Copyright 2007 by Davide Icardi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid