It’s pretty hard to find information about XMLRPC.net library used with https.
The only documentation where an “https” URL can be set is here : http://xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html#2.3 but yet it does not explain exactly how can one setup correctly.
Experimenting on the base of samples provided in the downloads http://xmlrpcnet.googlecode.com/files/xml-rpc.net.2.5.0.zip I tried this :
Changes in the client.cs file of StateNameServer solution :
IStateName svr = (IStateName)Activator.GetObject(
typeof(IStateName), "https://localhost:5678/statename.rem");
What the server code looks like
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
props["port"] = 5678;
HttpChannel channel = new HttpChannel(
props,
null,
new XmlRpcServerFormatterSinkProvider()
);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(StateNameServer),
"statename.rem",
WellKnownObjectMode.Singleton);
The client obviously drops an exception when trying to contact the server using HTTPS because I don’t know how to configure it. Could someone help in anyway please ? What kind of stuff should I look for ?
Thanks a lot !
First, I would like to thank warmly Charles Cook for his help on this problem and for developing XMLRPC.NET.
Second, this sample is based on the XMLRPC.NET StateNameServer sample available for download here :
http://xml-rpc.net/download.html
So here is the solution :
1. Generate or get a [self-signed] certificate (using makecert.exe for example)
2. Add this certificate to your server configuration and specify the port you want to use with your XMLRPC.NET server (in this case 5678) using httpcfg.exe or another tool like HttpSysConfig (Open Source)
3. Implement your XMLRPC.NET server using the following code :
4. Implement your XMLRPC.NET client using the following code (the code also creates a new X509 client certificate)
Of course, I don’t give here the interface implementation for the ServerStateName but you’ll find it in the sample files using the download link at the top.
Remark :
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); will allow the server implementation to accept the self-signed certificate you generated by yourself. I think this is not necessary with certificates issued by certification authorities.If you find anything that could be improved and is incorrect it will be much appreciated.