Provide the ability to configure security with a X509Certificate object

Apr 23, 2012 at 3:10 PM
Edited Apr 23, 2012 at 3:12 PM


We configure the server in code using the CertificateConfig object. This object only allows for a FilePath configuration. 

We've extended CertificateConfig with the following property:


    X509Certificate Certificate { get; }

And change CertificateManager to look like this:


internal static X509Certificate Initialize(ICertificateConfig cerConfig)
            X509Certificate cert;

            //Handle a certificate from the store first
            if (cerConfig.Certificate == null)
                //To keep compatible with website hosting
                string filePath;

                if (Path.IsPathRooted(cerConfig.FilePath))
                    filePath = cerConfig.FilePath;
                    filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, cerConfig.FilePath);

                cert = new X509Certificate2(filePath, cerConfig.Password);
                cert=  cerConfig.Certificate;

            return cert;



However, I think it would be better that SuperSocket did it out of the box.

What do you think?


Apr 23, 2012 at 3:14 PM

In v1.5, SuperSocket will provide the function loading certificate from certificate store instead.

Apr 23, 2012 at 3:37 PM

I did an improvement just now, you can override the new created protected method GetCertificate() in AppServer class to provide your own certificate.