Click here to Skip to main content
15,881,803 members
Articles / Security

Securing WCF Service with Self Signed Certificates Programmatically

Rate me:
Please Sign up or sign in to vote.
4.96/5 (15 votes)
21 Apr 2015CPOL2 min read 38.3K   132   30  
Securing a WCF Service with self signed certificates programmatically
using System.Configuration;
using System.Collections.Generic;

namespace Certificate.Configuration
{
    [ConfigurationCollection(typeof(TrustedCertificateInfo), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
    public class TrustedCertificateInfoCollection : ConfigurationElementCollection
    {
        internal const string itemPropertyName = "certificateInfo";

        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMapAlternate; }
        }

        protected override string ElementName
        {
            get { return itemPropertyName; }
        }

        protected override bool IsElementName(string elementName)
        {
            return (elementName == itemPropertyName);
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return (TrustedCertificateInfo)element;
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new TrustedCertificateInfo();
        }

        public override bool IsReadOnly()
        {
            return false;
        }
    }
}

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 Code Project Open License (CPOL)


Written By
Software Developer (Senior) Telerik
Bulgaria Bulgaria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions