My XSockets.Net code works fine when I use a "ws://" URL, but when I try to implement a secure version, I can't get it to work.
I used the following C# example code as my guide:
//Sample 1 - Certificate from store public class ChuckNorrisConfig :
ConfigurationSetting {
public MyCustomConfig1() : base(new Uri("wss://my.server.ip.address:4502"))
{
this.CertificateLocation = StoreLocation.LocalMachine;
this.CertificateSubjectDistinguishedName = "cn=localmachine";
}
}
//Sample 2 - X509Certificate2
public class MyCustomConfig2 : ConfigurationSetting {
public ChuckNorrisConfig() : base(new Uri("wss://my.server.ip.address:4502"))
{
this.Certificate = new X509Certificate2("file.name", "password");// line 369
}
}
I get the following error:
ERROR 2014/09/07-19:50:16 Could not start XSockets server. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.Cryptography.CryptographicException: The system cannot find the file specifed.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password) at NET.Server.MyCustomConfig2..ctor() in C:\MyProjects\NET.Server\Program.cs:line 369 --- End of inner exception stack trace ---
It errors out on the line 369 which I've tagged with the comment. I don't know what "file.name" is supposed to be. How do I get the "file.name" of an SSL certificate? I've been using a self-signed test certificate I made, but I don't know where to get its "file.name" I wish there was an actual example of runnable code which I could reference, rather than having to look at generic stuff.
Does anyone have a full example of a working XSockets WSS implementation? I am using XSockets.Net version 3.0.6, thanks.